๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Spring MVC - @PropertySource ์‚ฌ์šฉ ์ค‘ FileNotFoundException: Could not open ServletContext resource ์—๋Ÿฌ Spring MVC - @PropertySource ์‚ฌ์šฉ ์ค‘ FileNotFoundException: Could not open ServletContext resource ์—๋Ÿฌ โš™๏ธ Spring Web MVC 5.2.6.RELEASE ์Šคํ”„๋ง ์›น MVC ํ”„๋กœ์ ํŠธ์—์„œ ํ”„๋กœํผํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. java.io.FileNotFoundException: Could not open ServletContext resource [/properties/data1.properties] ํ”„๋กœ์ ํŠธ์˜ ํ”„๋กœํผํ‹ฐ ํŒŒ์ผ ์œ„์น˜๋Š” src/main/resources/properties/data1.properties ๋ฉ”์ด๋ธ ํ”„๋กœ์ ํŠธ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋นŒ๋“œํ•˜๋ฉด resources ๋‚ด์˜ ํŒŒ์ผ๋“ค์ด classpath๋กœ ๋ณต์‚ฌ๋œ๋‹ค... 2020. 5. 6.
[IntelliJ] Spring Web MVC ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐ ์„ธํŒ… - ์ž๋ฐ” ์„ค์ • ์‚ฌ์šฉ [IntelliJ] Spring Web MVC ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐ ์„ธํŒ… - ์ž๋ฐ” ์„ค์ • ์‚ฌ์šฉ 1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ์ƒˆ๋กœ์šด Maven ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. Create from archetype ์ฒดํฌ, maven-archetype-webapp์„ ์„ ํƒํ•˜๊ณ  Next ํด๋ฆญ ํ”„๋กœ์ ํŠธ ์ •๋ณด ์ž…๋ ฅํ•˜๊ณ  Next ํด๋ฆญ ์‚ฌ์šฉํ•  Maven ์„ ํƒ ํ›„ Finish ํด๋ฆญ ๊ธฐ๋ณธ์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” pom.xml 4.0.0 com.atoz_develop project03 1.0-SNAPSHOT war project03 Maven Webapp http://www.example.com UTF-8 1.7 1.7 junit junit 4.11 test project03 maven-clean-plugin 3.1.0 maven-resources-plugi.. 2020. 5. 1.
[IntelliJ] Spring Web MVC ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐ ์„ธํŒ… - XML ์„ค์ • ์‚ฌ์šฉ [IntelliJ] Spring Web MVC ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐ ์„ธํŒ… - XML ์„ค์ • ์‚ฌ์šฉ ๐Ÿ’ก ๋ฒ„์ „ : JDK8 / Spring MVC 5.2.6.RELEASE / Tomcat 9 1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ์ƒˆ๋กœ์šด Maven ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. Create from archetype ์ฒดํฌ, maven-archetype-webapp์„ ์„ ํƒํ•˜๊ณ  Next ํด๋ฆญ ํ”„๋กœ์ ํŠธ ์ •๋ณด ์ž…๋ ฅํ•˜๊ณ  Next ํด๋ฆญ ์‚ฌ์šฉํ•  Maven ์„ ํƒ ํ›„ Finish ํด๋ฆญ ๊ธฐ๋ณธ์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” pom.xml 4.0.0 com.atoz_develop project03 1.0-SNAPSHOT war project03 Maven Webapp http://www.example.com UTF-8 1.7 1.7 junit junit 4.11 test proje.. 2020. 5. 1.
[Spring Boot/Spring Web MVC] ViewController๋ฅผ ์ด์šฉํ•ด์„œ ๋ทฐ ๋งคํ•‘ํ•˜๊ธฐ [Spring Boot/Spring Web MVC] ViewController๋ฅผ ์ด์šฉํ•ด์„œ ๋ทฐ ๋งคํ•‘ํ•˜๊ธฐ @GetMapping("/hello") public String hello() { return "hello"; } ์œ„์™€ ๊ฐ™์ด ํŠน์ • ์š”์ฒญ url์— ๋Œ€ํ•ด ์ปจํŠธ๋กค๋Ÿฌ ๋กœ์ง ์—†์ด ๋ฐ”๋กœ ๋ทฐ๋ฅผ ๋ฆฌํ„ดํ•˜๋Š” ๊ฒฝ์šฐ ViewController๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋ทฐ๋ฅผ ๋งคํ•‘ํ•  ์ˆ˜ ์žˆ๋‹ค. @Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/hello").setViewName("hell.. 2020. 3. 26.
[Spring] ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ - PropertyEditor, Converter ๊ทธ๋ฆฌ๊ณ  Formatter [Spring] ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ - PropertyEditor, Converter ๊ทธ๋ฆฌ๊ณ  Formatter 1. Data Binding(๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ)์˜ ์ •์˜ ๐Ÿ“ ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ ์›น์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•˜์—ฌ ์ „๋‹ฌ๋˜๋Š” ๊ฐ’์€ ์ฃผ๋กœ ๋ฌธ์ž์—ด์ด๋ฉฐ, ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” ์ด ๋ฌธ์ž์—ด์„ ๋„๋ฉ”์ธ ๊ฐ์ฒด์˜ ํ”„๋กœํผํ‹ฐ ํƒ€์ž…(int, date, boolean, ... ๋˜๋Š” ๋„๋ฉ”์ธ ๊ฐ์ฒด ํƒ€์ž… ๊ทธ ์ž์ฒด)์œผ๋กœ ๋ณ€ํ™˜์ด ํ•„์š”ํ•˜๋‹ค. ์ด๋ ‡๊ฒŒ ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๋ฌธ์ž์—ด ๊ฐ’์„ ํ”„๋กœํผํ‹ฐ ํƒ€์ž…์— ๋งž์ถฐ ๋ณ€ํ™˜ํ•˜์—ฌ ํ• ๋‹นํ•˜๋Š” ๊ฒƒ์„ ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ์ด๋ผ ํ•œ๋‹ค. 2. Spring์˜ ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ Spring์€ ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ ๊ธฐ๋Šฅ์„ ์—ฌ๋Ÿฌ ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ถ”์ƒํ™”ํ•˜์—ฌ ์ œ๊ณตํ•œ๋‹ค. ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ ์ธํ„ฐํŽ˜์ด์Šค๋Š” ์ฃผ๋กœ ์›น MVC์—์„œ ์‚ฌ์šฉํ•˜์ง€๋งŒ web์— ๊ตญํ•œ๋˜์–ด ํŠนํ™”๋œ ๊ธฐ๋Šฅ์ด ์•„๋‹ˆ๋ผ ์—ฌ๋Ÿฌ ๊ณณ.. 2020. 3. 6.
[Spring] ์Šคํ”„๋ง PSA [Spring] ์Šคํ”„๋ง PSA 1. PSA(Portable Service Abstraction) Spring์€ Spring Triangle์ด๋ผ๊ณ  ๋ถ€๋ฅด๋Š” ์„ธ ๊ฐ€์ง€ ๊ฐœ๋…์„ ์ œ๊ณตํ•ด์ค€๋‹ค. ๊ฐ๊ฐ IoC, AOP, PSA๋ฅผ ์ผ์ปซ๋Š”๋‹ค. Spring์˜ PetClinic ์˜ˆ์ œ๋ฅผ ๋ณด๋ฉด ์„œ๋ธ”๋ฆฟ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ž„์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  ์„œ๋ธ”๋ฆฟ์ด ์ „ํ˜€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค. ๋‹จ์ง€ @Controller ์• ๋…ธํ…Œ์ด์…˜์ด ๋ถ™์–ด์žˆ๋Š” ํด๋ž˜์Šค์—์„œ @GetMapping, @PostMapping๊ณผ ๊ฐ™์€ @RequestMapping ์• ๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•ด์„œ ์š”์ฒญ์„ ๋งคํ•‘ํ•œ๋‹ค. ์‹ค์ œ๋กœ๋Š” ๋‚ด๋ถ€์ ์œผ๋กœ ์„œ๋ธ”๋ฆฟ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฝ”๋“œ๊ฐ€ ๋™์ž‘ํ•˜์ง€๋งŒ ์„œ๋ธ”๋ฆฟ ๊ธฐ์ˆ ์€ ์ถ”์ƒํ™” ๊ณ„์ธต์— ์˜ํ•ด ์ˆจ๊ฒจ์ ธ ์žˆ๋Š” ๊ฒƒ์ด๋‹ค. ์ด๋ ‡๊ฒŒ ์ถ”์ƒํ™” ๊ณ„์ธต์„ ์‚ฌ์šฉํ•ด์„œ ์–ด๋–ค ๊ธฐ์ˆ ์„ ๋‚ด๋ถ€์— ์ˆจ๊ธฐ๊ณ  ๊ฐœ๋ฐœ์ž์—๊ฒŒ ํŽธ์˜์„ฑ์„ ์ œ๊ณตํ•ด์ฃผ๋Š” .. 2020. 3. 1.