
[์คํ๋ง ํต์ฌ ์๋ฆฌ - ๊ธฐ๋ณธํธ] - 25. ํ๋กํ ํ์
์ค์ฝํ / Provider
ยท
Spring/Spring ๊ธฐ๋ณธ
ํ๋กํ ํ์
์ค์ฝํ - ์ฑ๊ธํค ๋น๊ณผ ํจ๊ป ์ฌ์ฉ์ ๋ฌธ์ ์ ์คํ๋ง ์ปจํ
์ด๋์ ํ๋กํ ํ์
์ค์ฝํ์ ๋น์ ์์ฒญํ๋ฉด ํญ์ ์๋ก์ด ๊ฐ์ฒด ์ธ์คํด์ค๋ฅผ ์์ฑํด์ ๋ฐํํ๋ค. ํ์ง๋ง ์ฑ๊ธํค ๋น๊ณผ ํจ๊ป ์ฌ์ฉํ ๋๋ ์๋ํ ๋๋ก ์ ๋์ํ์ง ์์ผ๋ฏ๋ก ์ฃผ์ํด์ผ ํ๋ค. ์์ clientBean ์ด๋ผ๋ ์ฑ๊ธํค ๋น์ด ์์กด๊ด๊ณ ์ฃผ์
์ ํตํด์ ํ๋กํ ํ์
๋น์ ์ฃผ์
๋ฐ์์ ์ฌ์ฉํ๋ ์๋ฅผ ๋ณด์. void prototypeFind() { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(PrototypeBean.class, ClientBean.class); clientBean ์ ์ฑ๊ธํค์ด๋ฏ๋ก, ๋ณดํต ์คํ๋ง ์ปจํ
์ด๋ ์์ฑ ์์ ์ ํจ๊ป ์์ฑ๋๊ณ , ์์กด๊ด๊ณ ์ฃผ์
..