I gave three presentations at the mini seminar held by DSC Ewha. In the second session, I covered the basic concepts of git and github, along with the most essential commands :)
Spring platform에 대한 기본 설정 뿐만아니라 다른 library에 대한 설정(tomcat)도 기본적으로 해준다
목표
모든 스프링 개발을 할 때 더 빠르고 더 폭넓은 사용성을 제공한다.
일일히 설정하지 않아도 convention으로 정해져있는 설정을 제공한다. 하지만 우리의 요구사항에 맞게 이런 설정을 쉽고 빠르게 바꿀 수 있다.(스프링 부트를 사용하는 이유)
non-fucntional 설정도 제공해 준다. 비즈니스로직 구현에 필요한 기능 외에도 non-functional feature도!
XML 사용하지 않고, code generation도 하지 않는다.
Spring 루 : 독특하게 code generation을 해주는데 지금은 잘 사용되지 않는다. generation을 안해서 더 쉽고 명확하고 커스터마이징하기 쉽다. > spring boot의 bb
System Requirements
Spring boot 는 java 8 이상을 필요로 한다.
지원하는 servletContainer로는 tomcat, jetty Undertow가 있다.
2. Spring Boot 시작하기
Intellij ultimate를 사용하면 Spring boot initializer가 있으나, community 버전은 없다. 따라서 자신이 원하는 build tool을 이용해서 만들어 주면된다 Spring boot initializer를 이용하지 않고, 프로젝트 생성하는 법 을 공부 할 것이다.
2-1. gradle project에서 시작
auto import OK (build.gradle 파일 변경할 때 마다 바로바로 변경 : dependency 추가 등)
원하는 build 형태의 spring boot project를 생성해준다. (dir 형태로!)
3. 스프링 프로젝트의 구조
gradle java 기본 프로젝트 구조와 동일하다
저장 파일
파일 경로
설명
소스 코드
src/main/java
-
소스 리소스
src/main/resource
java application에서 resources 기준으로 아래 것들을 참조 가능 (classpath)
테스트 코드
src/test/java
-
테스트 리소스
src/test/resource
test 관련 리소스를 만들 수 있다
메인 애플리케이션 위치 (@SpringBootApplication) : 기본 패키지 package com.jyami 프로젝트가 쓰고있는 가장 최상위 패키지! > why? 컴포넌트 스캔을 하기 때문
com.jyami에서부터 시작을 해서, 그 아래에 있는 파일들을 스캔해서 bean으로 등록한다.
src/main/java 위치에 넣으면 모든 패키지를 스캔하므로
만약 java>com.hello 패키지가 있고, 그안에 메인 애플리케이션이 아닌 java파일이 있으면, 그 java파일은 component 스캔이 이루어지지 않는다.
1. Introduction to Spring Boot
1-1. Spring Boot Start
Features
It's a tool that helps you build production-level applications, not just toy projects.
opinated view : This refers to the conventions that Spring Boot has (widely used configurations)
It provides default configurations not only for the Spring platform but also for other libraries (like tomcat) out of the box.
Goals
Provides faster and broader usability for all Spring development.
Provides convention-based configurations without having to set everything up manually. But you can easily and quickly change these settings to match your requirements. (This is the reason to use Spring Boot)
Provides non-functional configurations as well. Beyond features needed for business logic, it also covers non-functional features!
Does not use XML and does not do code generation.
Spring Roo : It uniquely does code generation, but it's not widely used anymore. By not doing generation, things are easier, clearer, and simpler to customize. > The predecessor of Spring Boot
System Requirements
Spring Boot requires Java 8 or higher.
Supported servlet containers include Tomcat, Jetty, and Undertow.
2. Getting Started with Spring Boot
If you use IntelliJ Ultimate, it has a Spring Boot Initializer built in, but the Community edition does not. So you can create one using whichever build tool you prefer. We'll learn how to create a project without using the Spring Boot Initializer.
2-1. Starting from a Gradle Project
auto import OK (Applies changes immediately whenever the build.gradle file is modified: adding dependencies, etc.)
Typically, a project declares dependencies on one or more "starters". Spring Boot simplifies dependency declarations and provides a useful Gradle plugin for generating jars.
package com.jyami;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String args[]){
SpringApplication.run(Application.class, args);
}
}
Using the SpringBootApplication annotation to call the method that runs SpringApplication
Spring MVC requires many dependencies to run — so how did all those dependencies get pulled in?
We need to configure the MVC app (bean, tomcat, etc.)
: This is all configured in @SpringBootApplication. > EnableAutoConfiguration
In IntelliJ settings, go to Build, Execution, Deployment > Compiler > Annotation Processors and check Enable annotation processing to be able to use annotations built with Gradle.
Run
When you run the application and check the logs, you can see that Tomcat is already running on port 8080. If you open http://localhost:8080, you can confirm that the Tomcat web application is working. (Even though it shows an error page)
Build
gradle build
This builds the package. Since it's a Java project, a jar file is generated.
It generates a Spring Boot project in your desired build format. (As a directory structure!)
3. Spring Project Structure
It follows the same structure as a standard Gradle Java project.
File Type
File Path
Description
Source Code
src/main/java
-
Source Resources
src/main/resource
In a Java application, files below the resources directory can be referenced (classpath)
Test Code
src/test/java
-
Test Resources
src/test/resource
You can create test-related resources here
Main Application Location (@SpringBootApplication) : Default package package com.jyami This should be in the topmost package of the project! > Why? Because of component scanning.
Starting from com.jyami, it scans files underneath and registers them as beans.
If you place it directly under src/main/java, it would scan all packages.
If there's a package java>com.hello with a Java file that isn't the main application, that Java file will not be picked up by component scanning.
2줄 전략 : merge + rebase 를 이용해서 git flow를 이쁘게 본다! 어느 시점에 반영이 됐는지 보기 위해서
feature
기능 브랜치
develop에서 갈라져 나온 기능 : git flow를 깔끔하게 보기 위해, origin develop의 갈라나온 시점을 잘 관리해 주어야 한다. git pull --rebase origin devlop 을 이용해서 제일 마지막에 반영된 develop에서 branch가 갈라 나온 것 처럼 보이게 한다.
Release version branch > Uses tags to record versions.
X . 0 : New project added
1 . X : New feature added
develop
Development branch
Two-line strategy: Use merge + rebase to keep the git flow looking clean! This helps you see at which point changes were integrated.
feature
Feature branch
Branches off from develop: To keep the git flow looking clean, you need to carefully manage the point where it diverges from origin develop. Use git pull --rebase origin devlop to make it look like the branch was created from the latest reflected develop.
hotfixes
Branch for fixing bugs found in the release version
After fixing in hotfixes, push to both develop and master.
release
QA fixes right before deployment
Same version as the beta server. After QA is done, push to both develop and master.
2. IntelliJ Shortcuts for Using GitHub Issues
ctrl+shift+a - Register GitHub in IntelliJ to access issues directly
alt+shift+n - Create a feature branch named after the issue.
3. Git Bash Commands Following the git-flow Strategy
댓글
Comments