Java 11 설치
IDE: IntelliJ 또는 Eclipse 설치
스프링 부트 스타터 사이트로 이동해서 스프링 프로젝트 생성
https://start.spring.io
src에 main과 test폴더가 나누어져 있음
main 안에 java와 resources파일 java밑에 실제 소스파일이 있다
test 폴더에는 test코드가 들어가 있음
test가 요즘 개발 트렌드에선 굉장히 중요하다
resources는 실제 자바 코드파일을 제외한 xml이나 설정파일 html
.gitignore에 깃허브에 올라가면 안되는 것들을 적는다
build.gradle 버전설정하고 라이브러리 댕겨오는 정도로만 이해
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
SpringApplication.run(HelloSpringApplication.class, args);
spring-boot-starter-web -> spring-boot-stater-tomcat/spring webmvc
Gradle은 의존관계가 있는 라이브러리를 함께 다운로드 한다
spring-boot-starter-thyemleafg -> thymeleaf-spring
타임리프와 관련된 라이브러리
package hello.hellospring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
@Controller
public class HelloController {
@GetMapping("hello")
public String hello(Model model) {
model.addAttribute("data", "hello!!");
return "hello";
}
}