์คํ๋ง ๋ถํธ ๋ก๊ทธ์ธ (1) - ์ฟ ํค, ์ธ์ ์ ์ด์ฉํด ๋ก๊ทธ์ธ ๊ธฐ๋ฅ ๊ตฌํํ๊ธฐ ์ธํ๋ฐ - ์คํ๋ง MVC 2ํธ - ๋ฐฑ์๋ ์น ๊ฐ๋ฐ ํ์ฉ ๊ธฐ์ ์ ๋ณด๊ณ ๊ณต๋ถํ๋ฉด์ ์ ๋ฆฌํ ๊ธ์ ๋๋ค. ์คํ๋ง ๋ถํธ์์ ์ฟ ํค์ ์ธ์ ์ ์ฌ์ฉํ์ฌ ๋ก๊ทธ์ธ ๊ธฐ๋ฅ์ ๊ตฌํํด ๋ณด์. ํ๋ก์ ํธ๋ ์คํ๋ง ๋ถํธ 2.4.9์ spring-boot-starter-web, spring-boot-starter-thymeleaf, spring-boot-starter-validation, lombok ์์กด์ฑ์ ์ถ๊ฐํ๋ค. ์์กด์ฑ๊ณผ ๊ฐ์ด ๋ทฐ ํ ํ๋ฆฟ์ thymeleaf๋ฅผ ์ฌ์ฉํ๋ค. Bootstrap ์ด๊ฑด ๊ผญ ํ์ํ๊ฑด ์๋๋ฏ๋ก ์คํตํด๋ ๋๋ค. https://getbootstrap.com/ ์์ bootstrap.min.css ํ์ผ์ ๋ฐ์ resources/static/css์ ์ถ๊ฐํ๋ค. ์ด์ ํ์ ๋๋ฉ์ธ ๊ฐ๋ฐ๋ถํฐ ์์ํด์ ๋ณธ๊ฒฉ์ ์ผ๋ก ๋ก๊ทธ์ธ ๊ธฐ๋ฅ.. 2021. 8. 13. 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] @Component ์ ๋ ธํ ์ด์ ๋ฐ ํจ๊ป ์ฌ์ฉํ๋ ์ ๋ ธํ ์ด์ ์ ๋ฆฌ [Spring] @Component ์ ๋ ธํ ์ด์ ๋ฐ ํจ๊ป ์ฌ์ฉํ๋ ์ ๋ ธํ ์ด์ ์ ๋ฆฌ ์คํ๋ง ๋น ์ค์ XML ํ์ผ์ ๋ ์๋ฐ @Configuration ํด๋์ค์์ @Bean์ ๋ถ์ฌ ๋น์ ๋ฑ๋กํ๋ ๊ฒ์ฒ๋ผ ๋น ํด๋์ค์ @Component ์ ๋ ธํ ์ด์ ์ ๋ถ์ฌ ๋น์ ๋ฑ๋กํ ์ ์๋ค. ์ฆ @Component๋ฅผ ์ฌ์ฉํด์ ๋น ์ค์ ํ์ผ์ด ์๋๋ผ ๋น ํด๋์ค์์ ๋น์ ์ง์ ๋ฑ๋กํ ์ ์๋ค. Component Scan ์ค์ @Component๋ฅผ ๋ถ์ธ ํด๋์ค๋ฅผ ์ค์บํ ์ ์๋๋ก ์ค์ ํด ์ฃผ์ด์ผ ํ๋ค. 1) XML ์ค์ ์ ์ฌ์ฉํ ๊ฒฝ์ฐ ํ๊ทธ์ base-package์ ์ค์บํ ํจํค์ง๋ฅผ ์ค์ ํ๋ค. ํจํค์ง๊ฐ ์ฌ๋ฌ๊ฐ์ธ ๊ฒฝ์ฐ ๋ฅผ ์ฌ๋ฌ๊ฐ ์์ฑํ ์ ์๋ค. 2) @Configuration ์ค์ ์ ์ฌ์ฉํ ๊ฒฝ์ฐ @Configuration // ์ง์ ๋ .. 2020. 4. 25. [Spring MVC] Static Resources(์ ์ ๋ฆฌ์์ค) ์ค์ ๋ฐฉ๋ฒ [Spring MVC] Static Resources(์ ์ ๋ฆฌ์์ค) ์ค์ ๋ฐฉ๋ฒ ์คํ๋ง MVC ์น ํ๋ก์ ํธ๋ ์ ์ ๋ฆฌ์์ค๋ฅผ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ผ๋ก ์ค์ ํ ์ ์๋ค. ์คํ๋ง XML ์ค์ ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ WebMvcConfigurer ์ธํฐํ์ด์ค๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด๋ค. ์์ ๊ฐ์ ํ๋ก์ ํธ ๊ตฌ์กฐ์์ {ํ๋ก์ ํธ ๋ฃจํธ}/src/main/webapp/resources ์์น์ ์ ์ ๋ฆฌ์์ค๋ฅผ ์ค์ ํ๋ค๊ณ ๊ฐ์ ํด๋ณด์. ์ด resources ๋๋ ํ ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ด ์คํ๋ง ์น ์ดํ๋ฆฌ์ผ์ด์ ์ ์ ์ ๋ฆฌ์์ค๋ก ์ค์ ํ ์ ์๋ค. 1. ์คํ๋ง MVC ์ ์ ๋ฆฌ์์ค XML ์ค์ ๋ฐฉ๋ฒ ํ๋ก์ ํธ์์ ์ฌ์ฉํ๋ ์คํ๋ง XML ์ค์ ํ์ผ์(servlet-context.xml ...) ๋ค์ ํ๊ทธ๋ฅผ ์ถ๊ฐํ๋ค. ์คํ๋ง IoC ์ปจํ ์ด๋ XML ์ค์ ํ์ผ mapp.. 2020. 4. 15. [Spring] ์คํ๋ง XML ์ค์ → ์ ๋ ธํ ์ด์ ์ค์ ๋ณํ ๋ฐฉ๋ฒ [Spring] ์คํ๋ง XML ์ค์ โ ์ ๋ ธํ ์ด์ ์ค์ ๋ณํ ๋ฐฉ๋ฒ ์คํ๋ง ํ๋ ์์ํฌ๋ฅผ ์ฌ์ฉ์ XML ์ค์ ์ ์ด์ฉํ๋ ๋ฐฉ๋ฒ๊ณผ ์๋ฐ ์ ๋ ธํ ์ด์ ๊ธฐ๋ฐ์ ์ค์ ์ ์ด์ฉํ๋ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ์ผ๋ก ๊ตฌ๋ถํ ์ ์๋ค. (์ฐธ๊ณ - ์คํ๋ง XML ์ค์ ๋ฐฉ๋ฒ : [Spring] ์คํ๋ง XML ์ค์ ํ์ผ ์์ฑ ๋ฐฉ๋ฒ ์ ๋ฆฌ) ๋ณธ ๊ธ์์๋ ์คํ๋ง์ XML ์ค์ ์ ์ ๋ ธํ ์ด์ ์ค์ ์ผ๋ก ๋ณํํ๋ ๋ฐฉ๋ฒ์ ๋ํด ๋ค๋ฃฌ๋ค. ๐ ๋ชฉ์ฐจ 1. ์คํ๋ง ์ ๋ ธํ ์ด์ ๊ธฐ๋ฐ ์ค์ ๊ธฐ๋ณธ ํฌ๋งท 2. ๊ธฐ๋ณธ์ ์ธ ๋น ์ค์ ๋ฐฉ๋ฒ - ์๋ ์ฃผ์ ์ค์ - autowire ์์ฑ 3. DI(Dependency Injection) ์ค์ - ์์ฑ์ ์ฃผ์ - ํ๋กํผํฐ ์ฃผ์ - ํ๋กํผํฐ ์ฃผ์ - List ํ์ - ํ๋กํผํฐ ์ฃผ์ - Map ํ์ 4. ApplicationContext ๊ฐ์ฒด.. 2020. 4. 14. [Spring] ์คํ๋ง ๋น(Bean) ์ด๊ธฐํ, ์๋ฉธ ์ ํน์ ์์ ์ ํ๋ ๋ฐฉ๋ฒ [Spring] ์คํ๋ง ๋น(Bean)์ด ์ด๊ธฐํ, ์๋ฉธ ์ ํน์ ์์ ์ ํ๋ ๋ฐฉ๋ฒ ๋ฐฉ๋ฒ 1: InitializingBean, DisposableBean ์ธํฐํ์ด์ค ๊ตฌํ ๋ฐฉ๋ฒ 2: ์คํ๋ง XML ์ค์ ์ฌ์ฉ 1. ์ธํฐํ์ด์ค ๊ตฌํ Spring์์ ์ ๊ณตํ๋ InitializingBean, DisposableBean ์ธํฐํ์ด์ค๋ฅผ ๊ตฌํํ๋ค. public class BookDao implements InitializingBean, DisposableBean { @Override public void afterPropertiesSet() throws Exception { // ๋น ์ด๊ธฐํ ์ ์ฝ๋ ๊ตฌํ } @Override public void destroy() throws Exception { // ๋น ์๋ฉธ ์ ์ฝ๋ ๊ตฌ.. 2020. 4. 13. [Spring] ์์กด์ฑ ์ฃผ์ ์ ๋ ธํ ์ด์ ์ ๋ฆฌ - @Autowired, @Resource, @Inject [Spring] ์์กด์ฑ ์ฃผ์ ์ ๋ ธํ ์ด์ ์ ๋ฆฌ - @Autowired, @Resource, @Inject 1. @Autowired @Autowired๋ ์ฃผ์ ํ๋ ค๊ณ ํ๋ ๊ฐ์ฒด์ ํ์ ์ด ์ผ์นํ๋ ๊ฐ์ฒด๋ฅผ ์๋์ผ๋ก ์ฃผ์ ํ๋ค. @Autowired๋ ํ๋, ์์ฑ์, Setter์ ๋ถ์ผ ์ ์๋ค. ๋จ, @Autowired๋ฅผ ํ๋, Setter์ ๋ถ์ฌ์ ์ฌ์ฉํ ๊ฒฝ์ฐ ๋ฐ๋์ ๊ธฐ๋ณธ ์์ฑ์๊ฐ ์ ์๋์ด ์์ด์ผ ํ๋ค. 1) @Autowired - ํ๋ ์ฃผ์ public class WordRegisterServiceUseAutowired { @Autowired private WordDao wordDao; public WordRegisterServiceUseAutowired() { } } 2) @Autowired - ์์ฑ์ ์ฃผ์ p.. 2020. 4. 13. [Spring] ์คํ๋ง XML ์ค์ ํ์ผ ์์ฑ ๋ฐฉ๋ฒ ์ ๋ฆฌ [Spring] ์คํ๋ง XML ์ค์ ํ์ผ ์์ฑ ๋ฐฉ๋ฒ ์ ๋ฆฌ ๐ ๋ชฉ์ฐจ 1. ์คํ๋ง XML ์ค์ ํ์ผ ํฌ๋งท - ๊ธฐ๋ณธ ํฌ๋งท - ์ ๋ ธํ ์ด์ ์ค์ ์ ์ฌ์ฉํ๊ธฐ ์ํ ํฌ๋งท 2. ๋น(Bean) ์ค์ ์์ - ์๋ ์ฃผ์ ์ค์ - autowire ์์ฑ 3. DI(Dependency Injection) ์ค์ - ์์ฑ์ ์ฃผ์ - ํ๋กํผํฐ ์ฃผ์ - ํ๋กํผํฐ ์ฃผ์ - List ํ์ - ํ๋กํผํฐ ์ฃผ์ - Set ํ์ - ํ๋กํผํฐ ์ฃผ์ - Map ํ์ - ํ๋กํผํฐ ์ฃผ์ - Properties ํ์ 4. ApplicationContext ๊ฐ์ฒด ์์ฑ - ์คํ๋ง XML ์ค์ ํ์ผ์ด ํ ๊ฐ์ธ ๊ฒฝ์ฐ - ์คํ๋ง XML ์ค์ ํ์ผ์ด ์ฌ๋ฌ ๊ฐ์ธ ๊ฒฝ์ฐ - ์คํ๋ง XML ์ค์ ํ์ผ์ด ์ฌ๋ฌ ๊ฐ์ธ ๊ฒฝ์ฐ(import ํ๊ทธ ์ฌ์ฉ) 1. ์คํ๋ง XML ์ค์ ํ.. 2020. 4. 13. [IntelliJ] ์คํ๋ง ๋ถํธ ์์ด ์คํ๋ง ์น MVC ํ๋ก์ ํธ ๋ง๋ค๊ณ ์ค์ ํ๊ธฐ [IntelliJ] ์คํ๋ง ๋ถํธ ์์ด ์คํ๋ง ์น MVC ํ๋ก์ ํธ ๋ง๋ค๊ณ ์ค์ ํ๊ธฐ โป ์ฌ์ฉ IDE : IntelliJ IDEA 2019.3 Ultimate 1. ์ ํ๋ก์ ํธ ์์ฑ ์ฌ์ฉํ๋ ๋น๋ํด(Maven, Gradle) ๊ธฐ๋ฐ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค. ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค. 1) ์ฌ์ฉํ ๋น๋ํด ์ ํ - ์ด ๊ธ์์๋ Maven์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. 2) ์ฌ์ฉํ JDK ์ ํ 3) Next ํด๋ฆญ ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ์ ๋ ฅํ๊ณ Finish๋ฅผ ํด๋ฆญํด์ ํ๋ก์ ํธ ์์ฑ์ ์๋ฃํ๋ค. 2. ํ๋ก์ ํธ ์ธํ 1. Java Compiler ๋ฒ์ ๋ณ๊ฒฝ 2. ํ๋ก์ ํธ์ Web Facet ์ถ๊ฐ 3. war packaging ์ค์ Maven ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ฉด ๊ธฐ๋ณธ Java Compiler ๋ฒ์ ์ด 1.5๋ก ๋์ด์๊ธฐ ๋๋ฌธ์ ๋ณ๊ฒฝ์ด ํ์ํ๋ค. S.. 2020. 3. 17. Servlet์์ ์คํ๋ง ApplicationContext ์ฌ์ฉํ๊ธฐ Servlet์์ ์คํ๋ง ApplicationContext ์ฌ์ฉํ๊ธฐ pom.xml org.springframework spring-webmvc 5.1.3.RELEASE ์คํ๋ง ApplicationContext, ์ฆ ์คํ๋ง IoC๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด ๊ด๋ จ ์์กด์ฑ์ ์ถ๊ฐํด์ผ ํ๋ค. spring-context ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ์ ธ์ฌ ์ ์๋๋ก ์์กด์ฑ์ ์ถ๊ฐํ๋ค. ์ ์์ ์์๋ spring-webmvc๋ฅผ ๊ฐ์ ธ์ค๋๋ก ํ์ง๋ง spring-context๋ง ๊ฐ์ ธ์๋ ๋๋ค. web.xml org.springframework.web.context.ContextLoaderListener contextClass org.springframework.web.context.support.AnnotationConfigWebApplication.. 2020. 3. 11. ์ด์ 1 2 3 ๋ค์