[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. 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. [Spring] ResourceLoader๋ก ํ ์คํธ ํ์ผ ์ถ๋ ฅํ๊ธฐ (Java 11) [Spring] ResourceLoader๋ก ํ ์คํธ ํ์ผ ์ถ๋ ฅํ๊ธฐ (Java 11) Spring์ ApplicationContext๋ ResourceLoader๋ผ๋ ์ธํฐํ์ด์ค๋ฅผ ์์ํ๋ค. ์ด ์ธํฐํ์ด์ค๋ ์ด๋ฆ์์๋ถํฐ ์ ์ ์๋ฏ ๋ฆฌ์์ค๋ฅผ ์ฝ์ด์ค๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค. 1. Resource ๊ฐ์ฒด ์ป๊ธฐ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.sprin.. 2020. 3. 5. [Spring] Spring ์ดํ๋ฆฌ์ผ์ด์ ๋ฉ์์ง ๋ค๊ตญ์ด ๋ฐ ์ฌ๋ก๋ฉ ์ฒ๋ฆฌ [Spring] Spring ์ดํ๋ฆฌ์ผ์ด์ ๋ฉ์์ง ๋ค๊ตญ์ด ๋ฐ ์ฌ๋ก๋ฉ ์ฒ๋ฆฌ Spring IoC ์ปจํ ์ด๋ = ApplicationContext๊ฐ ๊ฐ๊ณ ์๋ ๊ธฐ๋ฅ ์ค MessageSource๋ ๊ตญ์ ํ(i18n)์ ๊ด๋ จ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํด์ฃผ๋๋ฐ ์ด๋ฅผ ์ด์ฉํด์ ์ดํ๋ฆฌ์ผ์ด์ ์์ ์ถ๋ ฅํ๋ ๋ฉ์์ง๋ฅผ ๋ค๊ตญํํ ์ ์๋ค. 1. ๋ฉ์์ง ํ์ผ ์์ฑ resources ๋๋ ํ ๋ฆฌ ์๋์ messages.properties, messages_ko_KR.properties ํ์ผ์ ์๋ก ์์ฑํ๋ค. ์ฌ๊ธฐ์ ์ดํ๋ฆฌ์ผ์ด์ ์์ ์ถ๋ ฅํ ๋ฉ์์ง๋ฅผ messages.properties์๋ ์์ด๋ก, messages_ko_KR.proeprties์๋ ํ๊ตญ์ด๋ก ์์ฑํ ๊ฒ์ด๋ค. ํ์ผ๋ช ์ ์คํ๊ฐ ๋์ง ์๋๋ก ์กฐ์ฌํ์. ํ์ผ์ ์์ฑํ๊ณ ๋๋ฉด ์๋์ผ๋ก 'messages.. 2020. 3. 4. [Spring] EnvironmentCapable - Property ์ฌ์ฉํ๊ธฐ ๊ด๋ จ ๊ธ - JAVA ์น ํ๋ก์ ํธ์์ Properties ํ์ผ ํ์ฉํ๊ธฐ - [Spring] EnvironmentCapable - Profile ์ฌ์ฉํ๊ธฐ [Spring] EnvironmentCapable - Property ์ฌ์ฉํ๊ธฐ ApplicationContext๋ EnvironmentCapable์ ์์๋ฐ์ผ๋ฉฐ, EnvironmentCapable์ด ์ ๊ณตํ๋ ์ฃผ์ ๊ธฐ๋ฅ์๋ profile๊ณผ property๊ฐ ์๋ค. ๋ณธ ํฌ์คํ ์์๋ ๊ทธ ์ค property์ ๋ํด ์ดํด๋ณธ๋ค. 1. Property ๊ธฐ๋ฅ ์ดํ๋ฆฌ์ผ์ด์ ์์ ์ฌ์ฉ๋๋ ์ฌ๋ฌ๊ฐ์ง key, value ์์ผ๋ก ์ ๊ณต๋๋ ํ๋กํผํฐ์ ๊ฐํธํ๊ฒ ์ ๊ทผํ ์ ์๋ ๊ธฐ๋ฅ์ด๋ค. Spring์ ํ๋กํผํฐ์ '๊ณ์ธตํ'์ผ๋ก ์ ๊ทผํ๋๋ฐ ๊ณ์ธตํ์ผ๋ก ์ ๊ทผํ๋ค๋ ๋ง์ ํ๋กํผํฐ์ ์ฐ์ ์์๊ฐ.. 2020. 3. 4. [Spring] EnvironmentCapable - Profile ์ฌ์ฉํ๊ธฐ [Spring] EnvironmentCapable - Profile ์ฌ์ฉํ๊ธฐ Spring์ ApplicationContext๋ BeanFactory ๊ธฐ๋ฅ๋ง ํ๋๊ฑด ์๋๋ค. ApplicationContext๊ฐ ์์๋ฐ๋ ๋ค์ํ ์ธํฐํ์ด์ค๋ค ์ค EnvironmentCapable ์ธํฐํ์ด์ค๋ 'Profile(ํ๋กํ์ผ)' ์ด๋ผ๋ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค. Profile(ํ๋กํ์ผ)์ ๊ฐ๋ ํ๋กํ์ผ = ๋น๋ค์ ๋ฌถ์ ํ๋กํ์ผ์ ํน์ ์คํ ํ๊ฒฝ์์ ์ฌ์ฉํ ๋น๋ค์ ๋ฌถ์์ด๋ค. ํ ์คํธ ํ๊ฒฝ์์ ์ฌ์ฉํ ๋น ๋ฌถ์๊ณผ ํ๋ก๋์ (์ด์) ํ๊ฒฝ์์ ์ฌ์ฉํ ๋น ๋ฌถ์์ด ์๋ก ๋ค๋ฅผ ์ ์๋ค. ๋ ๊ฐ ํ๊ฒฝ์ ๋ฐ๋ผ ์๋ก ๋ค๋ฅธ ๋น๋ค์ ์จ์ผํ๋ ๊ฒฝ์ฐ, ํน์ ํ๊ฒฝ์์๋ง ๋ฑ๋กํด์ผํ๋ ๋น๋ค์ด ์๋ ๊ฒฝ์ฐ๊ฐ ์์ ์ ์๋ค. ํ๋กํ์ผ์ ๊ทธ๋ฌํ ์๊ตฌ์ฌํญ์ ์ถฉ์กฑํ ์ ์๋.. 2020. 3. 4. [Spring] ๋น์ ์ค์ ํ๋ 3๊ฐ์ง ๋ฐฉ๋ฒ - XML, JAVA, Component Scan [Spring] ๋น์ ์ค์ ํ๋ 3๊ฐ์ง ๋ฐฉ๋ฒ - XML, JAVA, Component Scan ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ค. ์์ ์ฝ๋์ ํ์ํ ์์กด์ฑ์ ๋ฐ๊ธฐ ์ํด spring boot ํ๋ก์ ํธ๋ฅผ ์์ฑํ ๊ฒ์ด๋ค. ์ฐธ๊ณ ๋ก ์์ ์ฝ๋์๋ ์ด ์์กด์ฑ์ด ํ์ํ๋ค. Spring Initializr๋ฅผ ์ ํํ๊ณ Next๋ฅผ ํด๋ฆญํ๋ค. Group, Artifact, Name์ ์ ๋ ฅํ๊ณ Next๋ฅผ ํด๋ฆญํ๋ค. Group์ ํจํค์ง๋ช ์ ์ ์ด์ค๋ค. (๋ณดํต ๋๋ฉ์ธ๋ช ์ ๋ค์ง์ด์..) Web - Spring Web์ ๋ฃ๊ณ Next๋ฅผ ํด๋ฆญํ๋ค. Finish๋ฅผ ํด๋ฆญํด์ ์ ๊ท ํ๋ก์ ํธ ์์ฑ์ ์๋ฃํ๋ค. Spring boot ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์๋ค. pom.xml์ ์ด์ด๋ณด๋ฉด spring boot 2.2.5 ๋ฒ์ ์ผ๋ก ๋ง๋ค์ด์ก์์ ํ์ธํ ์ ์๋ค. ์ฐ์ธก์.. 2020. 3. 1. ์ด์ 1 ๋ค์