๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Springboot

(22)
[spring boot] HATEOAS ๊ฐ„๋‹จํ•˜๊ฒŒ ์‚ฌ์šฉํ•ด๋ณด๊ธฐ HATEOAS ๋ž€? Hypermedia As The Engine Of Application State ์˜ ์•ฝ์ž์ด๋‹ค. rest API์—์„œ, ์„œ๋ฒ„๋Š” ํ˜„์žฌ ๋ฆฌ์†Œ์Šค์™€ ์—ฐ๊ด€๋œ ๋งํฌ ์ •๋ณด๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ œ๊ณตํ•œ๋‹ค. ํด๋ผ์ด์–ธํŠธ๋Š” ์—ฐ๊ด€๋œ ๋งํฌ ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ๋ฆฌ์†Œ์Šค์— ์ ‘๊ทผํ•œ๋‹ค. ์—ฐ๊ด€๋œ ๋งํฌ ์ •๋ณด: Relation Hypertext Reference; HATEOAS ๊ฐ„๋‹จํ•˜๊ฒŒ ์‚ฌ์šฉํ•ด๋ณด๊ธฐ spring-boot-starter-hateoas ์˜์กด์„ฑ ์ถ”๊ฐ€ org.springframework.boot spring-boot-starter-hateoas Entity ์ž‘์„ฑ @Getter @Setter @noargsconstructor public class Hello { private String prefix; private Strin..
[spring boot] ์•„์ฃผ ๊ฐ„๋‹จํ•˜๊ฒŒ Thymeleaf ์‚ฌ์šฉํ•ด๋ณด๊ธฐ ํ…œํ”Œ๋ฆฟ ์—”์ง„์ด๋ž€? ํ…œํ”Œ๋ฆฟ ์–‘์‹๊ณผ ํŠน์ • ๋ฐ์ดํ„ฐ ๋ชจ๋ธ์— ๋”ฐ๋ฅธ ์ž…๋ ฅ ์ž๋ฃŒ๋ฅผ ๊ฒฐํ•ฉํ•˜์—ฌ ์›ํ•˜๋Š” ๊ฒฐ๊ณผ ๋ฌธ์„œ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์†Œํ”„ํŠธ์›จ์–ด(๋˜๋Š” ์ปดํฌ๋„ŒํŠธ)๋ฅผ ๋งํ•œ๋‹ค. ์ฃผ๋กœ View๋ฅผ ๋งŒ๋“ค ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ๋™์  ์ปจํ…์ธ ๋ฅผ ์ƒ์„ฑํ•ด์„œ ์ œ๊ณตํ•ด์•ผํ•  ๋•Œ ํ…œํ”Œ๋ฆฟ ์—”์ง„์„ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. Code Generation / Email Template ๋“ฑ์— ์‚ฌ์šฉ๋œ๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ๊ฐ€ ์ž๋™ ์„ค์ •์„ ์ง€์›ํ•˜๋Š” ํ…œํ”Œ๋ฆฟ ์—”์ง„ FreeMarker Groovy Thymeleaf (์ถ”์ฒœ) ใ…ก> ๋น„๊ต์  ์ตœ๊ทผ์— ๋งŒ๋“ค์–ด์ง„ ํ…œํ”Œ๋ฆฟ ์—”์ง„์ด๋‹ค. Mustache JSP๋ฅผ ๊ถŒ์žฅํ•˜์ง€ ์•Š๋Š” ์ด์œ  spring boot๊ฐ€ ์ง€ํ–ฅํ•˜๋Š” ๋ฐ”๋ฅผ ์ถฉ์กฑ์‹œํ‚ค๊ธฐ ๋ชปํ•œ๋‹ค. spring boot๋Š” ๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰๊ฐ€๋Šฅํ•œ embeded tomcat์œผ๋กœ application์„ ์‰ฝ๊ณ  ๋น ๋ฅด๊ฒŒ ๋งŒ๋“ค์–ด ๋ฐฐํฌ..
[spring boot] index.html, favicon ์›ฐ์ปด ํŽ˜์ด์ง€ application์˜ root๋กœ ์š”์ฒญํ–ˆ์„ ๋•Œ ๋ณด์—ฌ์ฃผ๋Š” ํŽ˜์ด์ง€์ด๋‹ค. 1. ๊ธฐ๋ณธ ๋ฆฌ์†Œ์Šค ์œ„์น˜์—์„œ index.html ์ฐพ์•„ ๋ณด๊ณ  ์žˆ์œผ๋ฉด ์ œ๊ณตํ•˜๊ณ  2. index.ํ…œํ”Œ๋ฆฟ ์ฐพ์•„ ๋ณด๊ณ  ์žˆ์œผ๋ฉด ์ œ๊ณตํ•˜๊ณ  3. ๋‘˜ ๋‹ค ์—†์œผ๋ฉด ์—๋Ÿฌ ํŽ˜์ด์ง€๋ฅผ ๋ณด๋‚ด์ค€๋‹ค. favicon ๋ธŒ๋ผ์šฐ์ € ์ฐฝ ์ œ๋ชฉ ์˜†์˜ ์•„์ด์ฝ˜์„ ์˜๋ฏธํ•œ๋‹ค. favicon.ico ์ด๋ฆ„์œผ๋กœ ํด๋”์— ์ถ”๊ฐ€ํ•œ๋‹ค. ์‰ฝ๊ฒŒ favicon ๋งŒ๋“ค๊ธฐ ์‚ฌ์ดํŠธ: https://favicon.io/ favicon์ด ์ ์šฉ์ด ๋˜์ง€ ์•Š์„ ๋•Œ๋Š” "๊ฐ•๋ ฅํ•œ ์ƒˆ๋กœ๊ณ ์นจ(control + shift + R)"์„ ํ•ด๋ณด์ž ! ! ! ๋‚˜๋Š” resources/static/ ์— ์ €์žฅํ•ด๋‘์—ˆ๋‹ค. ๋‚ด๊ฐ€ ์ ์šฉํ•œ ๋ชจ์Šต์ด๋‹ค.
[spring boot] WebJars ์ค‘ jquery ์ถ”๊ฐ€ํ•ด๋ณด๊ธฐ WebJars๋ž€? ํด๋ผ์ด์–ธํŠธ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์›น๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(jquery, bootstrap, React.js, Vue.js, Angular ๋“ฑ) ๋ฅผ *JAR* ํŒŒ์ผ ์•ˆ์— ํŒจํ‚ค์ง•ํ•œ ๊ฒƒ์ด๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ๋Š” WebJars์— ๋Œ€ํ•œ ๊ธฐ๋ณธ mapping์„ ์ œ๊ณตํ•œ๋‹ค. ์‰ฝ๊ฒŒ ๋งํ•ด WebJars๋ฅผ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋‹ค. mvn repository์— ์˜ฌ๋ผ์™€์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฒ€์ƒ‰ํ•ด์„œ pom.xml์— ์ถ”๊ฐ€ํ•˜๊ณ  ์“ธ ์ˆ˜ ์žˆ๋‹ค. org.webjars.bower jquery 3.5.1 ๋ฒ„์ „ ์ƒ๋žตํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋ ค๋ฉด webjars-locator-core ์˜์กด์„ฑ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค. org.webjars webjars-locator-core 0.46
[spring boot] ์ •์  ๋ฆฌ์†Œ์Šค ์ง€์› ์ •์  ๋ฆฌ์†Œ์Šค๋ž€? ํด๋ผ์ด์–ธํŠธ๋กœ๋ถ€ํ„ฐ ์š”์ฒญ์ด ๋“ค์–ด์™”์„ ๋•Œ, ๋ฆฌ์†Œ์Šค๊ฐ€ ์ด๋ฏธ ๋งŒ๋“ค์–ด์ ธ ์žˆ์–ด์„œ ๊ทธ๋Œ€๋กœ ๋ณด๋‚ด์ฃผ๋ฉด ๋˜๋Š” ๊ฒฝ์šฐ๋ฅผ ๋งํ•œ๋‹ค. ๊ธฐ๋ณธ ๋ฆฌ์†Œ์Šค ์œ„์น˜ “/**”์ด mapping์— ์˜ํ•ด ์•„๋ž˜์˜ 4๊ฐ€์ง€ ํด๋”์˜ ์†Œ์Šค์™€ ์—ฐ๊ฒฐ์ด ๋œ๋‹ค. classpath:/static classpath:/public classpath:/resources/ classpath:/META-INF/resources ์˜ˆ์‹œ) /hello.html => /static/hello.html ๋งตํ•‘ ์„ค์ • ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ spring.mvc.static-path-pattern ์˜ˆ์‹œ) spring.mvc.static-path-pattern: /static/** => http://localhost:8080/static/hello.html ๋ฆฌ์†Œ์Šค ์ฐพ์„ ์œ„์น˜ ์ถ”๊ฐ€ ๊ฐ€๋Šฅ We..
[spring boot] HttpMessageConverters HttpMessageConverters HTTP ์š”์ฒญ ๋ณธ๋ฌธ์„ ๊ฐ์ฒด๋กœ ๋ณ€๊ฒฝํ•˜๊ฑฐ๋‚˜, ๊ฐ์ฒด๋ฅผ HTTP ์‘๋‹ต ๋ณธ๋ฌธ์œผ๋กœ ๋ณ€๊ฒฝํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ์Šคํ”„๋ง ํ”„๋ ˆ์ž„์›Œํฌ์—์„œ ์ œ๊ณตํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค์ด๊ณ , ์Šคํ”„๋ง mvc์˜ ์ผ๋ถ€๋ถ„์ด๋‹ค. ์˜ˆ์‹œ) ์ปจํ…์ธ ํƒ€์ž…์ด json์ธ ์š”์ฒญ์ด ๋“ค์–ด์™”๋‹ค๋ฉด json message converter๊ฐ€ User๋ผ๋Š” ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜ํ•ด์ค€๋‹ค. {“username”:”keesun”, “password”:”123”} User ๋ฆฌํ„ด ํƒ€์ž…์ด String์ด๋ฉด String message converter๊ฐ€ ์‚ฌ์šฉ์ด ๋œ๋‹ค. @ReuqestBody ์™€ @ResponseBody๋ฅผ ํ†ตํ•ด ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. @Controller public class UserController2 { @GetMapping("/hello") public @Re..
[spring boot] Test ์˜์กด์„ฑ์„ ํ™•์ธํ•˜์ž spring-boot-starter-test๊ฐ€ test ๊ธฐ๋Šฅ์„ ํ•ด์ค€๋‹ค. scope์€ test๋กœ ์ง€์ •ํ•˜๋ฉด ๋œ๋‹ค. org.springframework.boot spring-boot-starter-test test test ๋งŒ๋“ค๊ธฐ ๋‹จ์ถ•ํ‚ค: Alt+Insert @SpringBootTest @SpringBootTest๋Š” Spring main application, ์ฆ‰ @SpringBootApplication์„ ์ฐพ์•„๊ฐ€์„œ ์ดํ•˜์˜ ๋ชจ๋“  ๋นˆ์„ ์Šค์บ”ํ•˜๊ณ  test์šฉ application์— ๋“ฑ๋กํ•œ๋‹ค. ์–ด๋งˆ์–ด๋งˆํ•œ ํ†ตํ•ฉํ…Œ์ŠคํŠธ์ธ ๊ฒƒ์ด๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ฐ‘์— ๋‚˜์˜ค์ง€๋งŒ, MockBean๋งŒ ๊ต์ฒดํ•ด์ค€๋‹ค. ๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ํ…Œ์ŠคํŠธ ํ˜•ํƒœ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค. import org.junit.runner.RunWith; import org.s..
[spring boot] ๋กœ๊ฑฐ๋ฅผ Log4j2๋กœ ๋ณ€๊ฒฝํ•˜๊ธฐ docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging “How-to” Guides Spring Boot has no mandatory logging dependency, except for the Commons Logging API, which is typically provided by Spring Framework’s spring-jcl module. To use Logback, you need to include it and spring-jcl on the classpath. The recommended way to do th docs.spring.io org...
[spring boot] logging ์ปค์Šคํ„ฐ๋งˆ์ด์ง• https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html “How-to” Guides Spring Boot has no mandatory logging dependency, except for the Commons Logging API, which is typically provided by Spring Framework’s spring-jcl module. To use Logback, you need to include it and spring-jcl on the classpath. The recommended way to do th docs.spring.io Customize log file Logback: ํŒŒ์ผ..
[spring boot] logging ๊ธฐ๋ณธ ์„ค์ • log: (ํƒ€๋™์‚ฌ) ์ผ์ง€์— ๊ธฐ๋กํ•˜๋‹ค (๋งˆ์ง€๋ง‰ ํ™”์‚ดํ‘œ) JUL(java util logging)์€ SLF4j API๋กœ ๋ณด๋‚ธ๋‹ค. (์ค‘๊ฐ„ ํ™”์‚ดํ‘œ) Log4J๋„ SLF4j API๋กœ ๋ณด๋‚ธ๋‹ค. (์ฒ˜์Œ ํ™”์‚ดํ‘œ) Logback์ด SLF4j์˜ ๊ตฌํ˜„์ฒด์ด๋‹ค. Commons Logging, SLF4j๋Š” ์‹ค์ œ ๋กœ๊น…์„ ํ•˜๋Š” ์• ๋“ค์ด ์•„๋‹ˆ๋ผ ๋กœ๊ฑฐ API๋ฅผ ์ถ”์ƒํ™”ํ•ด๋‘” interface ์ด๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ Commons Logging์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ๊ฒฐ๊ตญ SLF4j์„ ์‚ฌ์šฉํ•˜๊ณ , SLF4j๋Š” ๊ตฌํ˜„์ฒด์ธ Logback์„ ์‚ฌ์šฉํ•˜์—ฌ ๋กœ๊น…(๊ธฐ๋ก)์„ ํ•œ๋‹ค. ์ตœ์ข…์ ์œผ๋กœ Logback์„ ์“ด๋‹ค. ์Šคํ”„๋ง ๋ถ€ํŠธ ๋กœ๊น…์˜ ๊ธฐ๋ณธ ํฌ๋งท ๋‚ ์งœ ์‹œ๊ฐ„ / ๋กœ๊ทธ ๋ ˆ๋ฒจ / PID / Thread ์ด๋ฆ„ / full package๊ฒฝ๋กœ.class์ด๋ฆ„ / ๋ฉ”์„ธ์ง€ ๋””๋ฒ„๊น… ..
@Profile Spring Framework์—์„œ ์ œ๊ณตํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ํŠน์ •ํ•œ ํ”„๋กœ ํŒŒ์ผ์—์„œ๋งŒ ํŠน์ •ํ•œ ๋นˆ์„ ๋“ฑ๋กํ•˜๊ณ  ์‹ถ๋‹ค๊ฑฐ๋‚˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋™์ž‘์„ ํŠน์ •ํ•œ ํ”„๋กœํŒŒ์ผ์—์„œ ๋นˆ ์„ค์ •์„ ๋‹ค๋ฅด๊ฒŒ ํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์“ด๋‹ค. @Profile @Profile("prod") // ์„ค์ •ํŒŒ์ผ ์ž์ฒด๊ฐ€ "prod"๋ผ๋Š” ํ”„๋กœํŒŒ์ผ์ผ ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ๋‹น์—ฐํžˆ hello ๋นˆ๋„ ๋ชป์“ด๋‹ค. @Configuration public class BaseConfiguration { @Bean public String hello(){ return "hello"; } } @Profile("test") // ์„ค์ •ํŒŒ์ผ ์ž์ฒด๊ฐ€ "test"๋ผ๋Š” ํ”„๋กœํŒŒ์ผ์ผ ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค. @Configuration public class TestConfiguration { @Bean publi..
[spring boot] ์™ธ๋ถ€ ์„ค์ • https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config ์™ธ๋ถ€ ์„ค์ •์ด๋ž€? ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์—ฌ๋Ÿฌ ์„ค์ • ๊ฐ’๋“ค์„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์•ˆ ๋˜๋Š” ๋ฐ–์—๋‹ค๊ฐ€ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ application.properties ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์„ค์ • ํŒŒ์ผ์€ application.properties ํŒŒ์ผ์ด๋‹ค. spring boot๊ฐ€ ์ž๋™์œผ๋กœ ๋กœ๋”ฉํ•˜๋Š” ํŒŒ์ผ ์ด๋ฆ„์œผ๋กœ, ๊ทœ์•ฝ(convention)์ด๋‹ค. key value ํ˜•ํƒœ๋กœ ์ •์˜ํ•œ๋‹ค. ๋‹ค ๋ฌธ์ž์—ด์ด๋‹ค. springboot intializr ์‹œ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ๋กœ, ๋ฐ‘์˜ ์šฐ์„ ์ˆœ์œ„์—์„œ 15์ˆœ์œ„์— ํ•ด๋‹นํ•œ๋‹ค. Spring Boot์˜ ์™ธ๋ถ€ ์„ค์ • ์ข…๋ฅ˜ propertie..
SpringApplication Spring Initializr๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์ƒ์„ฑ๋˜๋Š” Application ํด๋ž˜์Šค @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ์ปค์Šคํ„ฐ๋งˆ์ด์ง• ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ๋กœ์ปฌ ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค. SpringApplication app = new SpringApplication(Application.class); @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication app..
์Šคํ”„๋ง๋ถ€ํŠธ, ๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ JAR “๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰๊ฐ€๋Šฅํ•œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜”์ด ์Šคํ”„๋ง๋ถ€ํŠธ์˜ ์ฃผ์š”ํ•œ ๋ชฉ์  ์ค‘ ํ•˜๋‚˜์ด๋‹ค. org.springframework.boot spring-boot-maven-plugin pom.xml์˜ spring-boot-maven-plugin์ด ํ•ด์ฃผ๋Š” ์ผ์ด ๋ฐ”๋กœ ํŒจํ‚ค์ง•์ด๋‹ค. jar ์•ˆ์— jar ํŒŒ์ผ๋“ค์„ ๊ทธ๋Œ€๋กœ ๋ฌถ์–ด๋‘˜ ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•ด์„œ ํ•˜๋‚˜์˜ jar ํŒŒ์ผ๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ํŒจํ‚ค์ง•ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ชจ๋“  mvn ๋ช…๋ น์–ด๋Š” ํ”„๋กœ์ ํŠธ์˜ ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ์‹คํ–‰ํ•˜๋ฉด ๋œ๋‹ค. ์•„๋ž˜๋Š” ๋Œ€ํ‘œ์ ์œผ๋กœ ์“ฐ์ด๋Š” ๋ช…๋ น์–ด๋“ค์ด๋‹ค. mvn clean mvn package ใ…ก> ์‹คํ–‰ ๊ฐ€๋Šฅํ•œ JAR ํŒŒ์ผ “ํ•˜๋‚˜๊ฐ€" ์ƒ์„ฑ๋œ๋‹ค. mvn clean package ใ…ก> ํ•œ ๋ฒˆ์— ์‹คํ–‰ํ•  ์ˆ˜๋„ ์žˆ๋‹ค. mvn package -DskipTests ใ…ก> test๋Š” ๊ฑด๋„ˆ๋›ด๋‹ค. jav..
์Šคํ”„๋ง ๋ถ€ํŠธ ํฌํŠธ ๋ฒˆํ˜ธ ๋ณ€๊ฒฝ, ๋žœ๋คํฌํŠธ, ํฌํŠธ ๋ฒˆํ˜ธ ํ™•์ธํ•˜๊ธฐ ํฌํŠธ ๋ฒˆํ˜ธ ๋ณ€๊ฒฝํ•˜๊ธฐ server.port=7070 ๋žœ๋ค ํฌํŠธ๋กœ ๋ณ€๊ฒฝํ•˜๊ธฐ server.port=0 eventListener๋กœ ํฌํŠธ ๋ฒˆํ˜ธ ํ™•์ธํ•˜๊ธฐ ServletWebServerInitializedEvent๋Š” ์›น์„œ๋ฒ„๊ฐ€ ์ดˆ๊ธฐํ™”, ์ƒ์„ฑ์ด ๋˜๋ฉด ํ˜ธ์ถœ๋˜๋Š” eventListener์ด๋‹ค. ์„œ๋ธ”๋ฆฟ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ใ…ก> ์›น ์„œ๋ฒ„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด๊ธฐ ๋•Œ๋ฌธ์— ์›น ์„œ๋ฒ„๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋‹ค. package com.jueun.demo; import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext; import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent; i..
์Šคํ”„๋ง ๋ถ€ํŠธ์— ๋‚ด์žฅ๋œ tomcat ์„œ๋ฒ„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฒ• ๋‚ด์žฅ๋œ ํ†ฐ์บฃ ๋ง๊ณ  ๋‹ค๋ฅธ ์„œ๋ฒ„๋กœ ๋ณ€๊ฒฝํ•ด๋ณด์ž. jetty๋กœ ๋ณ€๊ฒฝ jetty๋ฅผ ์“ฐ๊ณ ์‹ถ๋‹ค๋ฉด spring-boot-starter-web์— ๋‚ด์žฅ๋˜์–ด tomcat๋ฅผ ์ œ์™ธ์‹œํ‚ค๊ณ  jettyspring-boot-starter-jetty๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค. org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-jetty undertow๋กœ ๋ณ€๊ฒฝ undertow๋ฅผ ์“ฐ๊ณ  ์‹ถ๋‹ค๋ฉด spring-boot-starter-undertow๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋˜๊ฒ ๋‹ค. org.springframework.boot spring-boot-starter..
์Šคํ”„๋ง ๋ถ€ํŠธ์˜ ๋‚ด์žฅ ์›น ์„œ๋ฒ„(๋” ์—„๋ฐ€ํžˆ ๋งํ•˜๋ฉด WAS)์— ๋Œ€ํ•˜์—ฌ ์Šคํ”„๋ง ๋ถ€ํŠธ๋Š” ์„œ๋ฒ„๊ฐ€ ์•„๋‹ˆ๋‹ค. ์›น ์„œ๋ฒ„๊ฐ€ ์•„๋‹Œ ํ˜•ํƒœ๋กœ ์‹คํ–‰ํ•˜๋Š” ๋ฒ• ๋ฐฉ๋ฒ• 1 ์Šคํ”„๋ง๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ์—์„œ main ๋ฉ”์†Œ๋“œ์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์„ฑํ•˜๋ฉด ๋œ๋‹ค. SpringApplication application = new SpringApplication(Application.class); application.setWebApplicationType(WebApplicationType.NONE); application.run(args); ํ•˜๋ฉด ์›น ์„œ๋ฒ„๊ฐ€ ์•„๋‹Œ ํ˜•ํƒœ๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ฐฉ๋ฒ• 2 ๋˜๋Š” main ๋ฉ”์†Œ๋“œ๋Š” ์›๋ž˜๋Œ€๋กœ ๋‘๊ณ  resources > application.properties ํŒŒ์ผ์— ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์„ฑํ•ด๋ณด์ž spring.main.web-application.type=none "ํ†ฐ์บฃ ๊ฐ์ฒด ์ƒ์„ฑํ•ด์„œ ํฌํŠธ๋ฒˆํ˜ธ ์„ค..
์Šคํ”„๋ง ๋ถ€ํŠธ์˜ Auto Configuration ์ง์ ‘ ๊ตฌํ˜„ํ•ด๋ณด๊ธฐ "Xxx-Spring-Boot-Starter" ์ž๋™ ์„ค์ •์„ ์ง์ ‘ ๊ตฌํ˜„ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. jueun-spring-boot-starter ๊ตฌํ˜„ํ•˜๊ธฐ 1. maven ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ, ์˜์กด์„ฑ ์ถ”๊ฐ€ 4.0.0 com.jueun jueun-spring-boot-starter 1.0-SNAPSHOT org.springframework.boot spring-boot-autoconfigure org.springframework.boot spring-boot-autoconfigure-processor true org.springframework.boot spring-boot-dependencies 2.0.3.RELEASE pom import 2. DTO(VO) ์ž‘์„ฑ package com.jueun; public class Ho..
์Šคํ”„๋ง ๋ถ€ํŠธ ์ž๋™์„ค์ • ๊ฐ„๋‹จํ•˜๊ฒŒ ์ดํ•ดํ•˜๊ธฐ bean์€ 2๋‹จ๊ณ„๋กœ ๋‚˜๋ˆ ์„œ ์ฝํžŒ๋‹ค. @SpringBootApplication ์•ˆ์— @ComponentScan์™€ @EnableAutoConfiguration์ด ์ˆจ์–ด์žˆ๋‹ค. 1๋‹จ๊ณ„: @ComponentScan @ComponentScan์€ ์Šคํ”„๋ง ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ํŠน์ • ํŒจํ‚ค์ง€ ์ดํ•˜์— ์žˆ๋Š” ๋ชจ๋“  ํด๋ž˜์Šค๋ฅผ ์ˆœํšŒํ•˜๋ฉด์„œ ๊ทธ ์œ„์— @Configuration, @Component, @Repository, @Service, @Controller, @RestController ๊ฐ™์€ ์• ๋…ธํ…Œ์ด์…˜์ด ๋ถ™์€ ํด๋ž˜์Šค๋ฅผ ๋นˆ์œผ๋กœ ๋“ฑ๋กํ•ด์ค€๋‹ค. 2๋‹จ๊ณ„: @EnableAutoConfiguration org.springframework.boot.autoconfigure.EnableAutoConfiguration @EnableAuto..
Springboot ์˜์กด์„ฑ ๊ด€๋ฆฌ์— ๋Œ€ํ•˜์—ฌ *1 spring-boot-starter-parent์˜ ๋ถ€๋ชจ๋Š” spring-boot-dependencies์ธ๋ฐ ์—ฌ๊ธฐ์— ์‚ฌ์ง„๊ณผ ๊ฐ™์ด properties๋กœ ๋ฒ„์ „์ด ๋ช…์‹œ๋˜์–ด ์žˆ๋‹ค. spring-boot-dependencies ํŒŒ์ผ์€ ์ปจํŠธ๋กค์„ ๋ˆ„๋ฅด๊ณ  ํด๋ฆญํ•˜๋ฉด ๋“ค์–ด๊ฐˆ ์ˆ˜ ์žˆ๋‹ค. ๋ฐ”๊พธ๊ณ  ์‹ถ์œผ๋ฉด properties์— ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค. 5.0.6.RELEASE *2 ์˜์กด์„ฑ ์ถ”๊ฐ€ ์‹œ intelliJ ์˜†์— ์‚ฌ์ง„๊ณผ ๊ฐ™์ด ํ‘œ์‹œ๊ฐ€ ๋œจ๋Š” ๊ฒƒ์€ ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ํ•ด์ฃผ๊ณ  ์žˆ์œผ๋ฏ€๋กœ ๋ฒ„์ „์„ ๋ช…์‹œํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ํ•˜์ง€๋งŒ ๋ฒ„์ „์„ ๋ช…์‹œํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•œ๋‹ค๊ณ  ํ•œ๋‹ค. *3 maven ์˜์กด์„ฑ์„ ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‹ถ์„ ๋•, https://mvnrepository.com/ ์—์„œ ๊ฒ€์ƒ‰ํ•˜๋ฉด ๋œ๋‹ค. *4 spring-boot-starter-parent๊ฐ€ ์ง€์ •ํ•ด์ฃผ..