Spring Boot
Spring ์ด๊ธฐ ์ค์ ์์ ๋ณธ ๊ฒ์ฒ๋ผ, Spring Legacy Project๋ฅผ ์์ฑํ ๊ฒฝ์ฐ ๋ฐฉ๋ํ๊ณ ๋ณต์กํ ์ด๊ธฐ ์ค์ (๋ผ์ด๋ธ๋ฌ๋ฆฌ, ์์กด์ฑ ๋ฑ)์ ์๋๋๊ธฐ ์ฝ๋ค.
SpringBoot๋ ์์ฃผ ์ฌ์ฉ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์กฐํฉ์ ๋ง๋ค์ด ๋ณต์กํ ์ค์ ์ ์๋์ผ๋ก ์ฒ๋ฆฌํ ์ ์๊ฒ ํ๋ Spring์ ๋ฐ์ ๋ ๋ฒ์ ์ด๋ผ๊ณ ์๊ฐํ๋ฉด ๋๋ค.
Spring Boot ํน์ง
- ๋ด์ฅ ์๋ฒ๋ฅผ ํฌํจํ๊ณ ์๊ธฐ๋๋ฌธ์ Tomcat๊ณผ ๊ฐ์ WAS๋ฅผ ์ถ๊ฐํ์ง ์๊ณ ๋ ์ฌ์ฉํ ์ ์๋ค.
- WARํ์ผ๋ฟ๋ง ์๋๋ผ JARํ์ผ ํํ๋ก ์น ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค ์ ์๋ค.
Spring Boot(Spring Starter Project)
Spring Starter Project ์์ฑ -> ํ๋ก์ ํธ ๋ช , Java Version, Packaging ๋ฑ ์ ํ -> Dependency ์ค์
Spring Legacy Project ์์ Spring Boot Project๋ก์ ๋ณํ
- src/main/java : java ์์ค ๋๋ ํฐ๋ฆฌ
- ํ๋ก์ ํธ๋ช
Application.java : Java ์์ค ๊ธฐ๋ฐ ์คํ๋ง ํ๋ก์ ํธ ํ๊ฒฝ ์ค์ ํ์ผ(@Configuration). 3 ๊ณ์ธต์ ํจํค์ง(com.capo.testapp) ํ์์ ์กด์ฌํ๋ ๋ชจ๋ Component๋ฅผ
auto scanํ๋ค. - static : css, js, img ๋ฑ ์ ์ ๋ฆฌ์์ค๋ฅผ ๋ชจ์๋ ๋๋ ํฐ๋ฆฌ
- src/main/webapp ํ์์ WEB-INF/views ๋๋ ํฐ๋ฆฌ๋ฅผ ์์ฑ : jsp์ ๊ฐ์ ๋์ ๋ฆฌ์์ค๋ฅผ ๋ชจ์๋ ๋๋ ํฐ๋ฆฌ
- application.properties : ์ ํ๋ฆฌ์ผ์ด์
ํน์ ์คํ๋ง ์ค์ ์์ ์ฌ์ฉํ๋ ์ฌ๋ฌ property๋ฅผ ์ ์ํ ํ์ผ. ๊ธฐ์กด Legacy Project์
db.properties,log4j.xml,web.xml,servlet-context.xml,root-context.xml๋ฑ์ ์ค์ ๋ด์ฉ์ ์ฌ๊ธฐ์ ์ค์ ํ๋ฉด ๋๋ค.
# context path ์ค์
server.servlet.context-path=/movieapp
server.port=9090
# db connection pool ์ค์
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/moviedb?serverTimezone=UTC
spring.datasource.username=ssafy
spring.datasource.password=ssafy
spring.datasource.type=org.apache.commons.dbcp2.BasicDataSource
# mybatis ์ค์
mybatis.mapper-locations=mapper/**/*.xml
mybatis.type-aliases-package=com.ssafy.movieapp.model.dto
# view resolver ์ค์ (jsp๋ฅผ ์ํจ)
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
# logging ๋ ๋ฒจ ์ค์
logging.level.com.ssafy.movieapp.controller=debug- servletInitializer.java : WAR๋ก ๋ฐฐํฌํ ๋ main ๋ฉ์๋(ํ๋ก์ ํธ๋ช Application.java ์ ์กด์ฌ)๊ฐ ์คํ๋ ์ ์๋๋ก ํ๋ ์ค์ ํ์ผ
