spring initializr : 스프링 부트 기반 프로젝트 만들어주는 사이트.
Maven과 Gradle
라이브러리를 데려오고 빌드하는 라이프사이틀 관리해주는 툴.
버전설정
Spring Boot 버전
snapshot 만드는 중
M1정식 릴리즈 아님
그룹은 기업도메인명
artifact 결과물(프로젝트명)
dependencies
어떤 라이브러리를 땡겨쓸거냐
spring web
http만드는 템플릿엔진 딱 맘에 드는 게 없어서 thymeleaf
build.gradle
group = 'hello'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
우리가 설정한대로, 11버전으로 다운로드
dependencies 에
아까 선택한 thymeleaf, web있고
testimplementation은 기본으로 들어감.
gitignore 깃 소스코드 관리.
실행했을 때 콘솔에 Tomcat started on port(s): 8080 (http) 가 뜬다.
그리고
Whitelabel Error Page
가 뜨면 성공!
스프링부트어플리케이션
톰캣이란 웹서버를 내장하고 있으면서 스프링부트가 같이 올라옴.
세팅에 그레이들
빌드 and run using
run tests using
그레이들말고 인텔리제이로 하면
돌릴 떄 그레이들 안 거치고 인텔리제이로 바로 되서 훨씬 빠르다고 함.
왼쪽 파일 목록에 External Libraries
외부에서 당겨온 라이브러리
thymeleaf 템플릿 엔진
thymeleaf 공식 사이트: https://www.thymeleaf.org/
스프링 공식 튜토리얼: https://spring.io/guides/gs/serving-web-content/
스프링부트 메뉴얼: https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/
html/spring-boot-features.html#boot-features-spring-mvc-template-engines
웹애플리케이션 첫번째 진입점이 컨트롤러
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'안녕하세요. ' + ${data}" >안녕하세요. 손님</p>
</body>
</html>
xmlns 이하 쓰면 thymeleaf 가져다 쓸 수 있다.