Spring
Spring | Annotation DI | @Autowired DI | ๊ฐ์ฒด์์ฑ -> xml, ๊ฐ์ฒด์ ๊ฐ์ฒด injection -> Annotation ์ฌ์ฉ
Annotation ์ฌ์ฉ ์ด์ XML๋ก ์ค์ ํ ๋ ๋ชจ๋ ๋ณ๊ฒฝ ๋ฐฉ๋ฒ์์ ์๋ก์ด ๊ฐ์ฒด๋ฅผ ์์ฑํด์ ๊ฒฐํฉ๋๊ฒ ํ๊ธฐ ์ํด์๋ xml์ ์ฌ์ฉํ์ ๊ฒฝ์ฐ์๋ xml๋ฅผ ์์ ํด์ผ ํ๋ ๋ถํธํจ์ด ์์๋ค. ๊ฐ์ฒด๋ฅผ ๋ฐ๊พธ๋ฉด ์ค์ ์ ๋ฐ๋ก ๋ฐ๊พธ๊ธฐ ์ํด์ ์ฝ๋์๋ค๊ฐ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ํฌํจํ๋ค. ์ธํฐํ์ด์ค์ ์ฐ๊ฒฐํ ๋ ์๋ก ์์ฑํ ๊ฐ์ฒด์ @Component Annotation๋ฅผ ๋ถ์ฌ์ฃผ๋ฉด ์์์ ์ค์ ํ์ผ ์์ด ๊ฐ์ฒดํํ๋ค. xml์์ Annotation์ผ๋ก ๋ณ๊ฒฝ ๊ฐ์ฒด์ ๊ฐ์ฒด๋ฅผ injection ํด์ฃผ๋ ์์
DI ๋ฐฉ์์ ์๋์ ๊ฐ์ด ๋ณ๊ฒฝ setter injection @Autowired xml๋ก ๊ฐ์ฒด๋ฅผ ๋ง๋ค์ด์ฃผ๋ฉด ์๋์ผ๋ก ์ธํ
์ ํด์ค๋ค. ๊ฐ์ฒด๋ฅผ ์์ฑํ์ ๋ Autowired์ค์ ์ ํ์ธํ๊ณ ์์ผ๋ฉด ๊ฐ์ฒด ์ฐธ์กฐ์ํค๋ ํค์๋ ๋ง๋ค์ด์ฃผ๊ธฐ Namespace..
2021. 2. 24. 11:19