๋ฐ์ํ


์คํ๋ง ์ปจํ ์ด๋
ApplicationContext

- ์ธํฐํ์ด์ค ์ด๋ค.
- ๊ตฌํ์ฒด new AnnotationConfigApplicationContext(AppConfig.class);
- ์คํ๋ง ์ปจํ ์ด๋๋ฅผ ์์ฑํ ๋ ๊ตฌ์ฑ ์ ๋ณด(AppConfig)๋ฅผ ์ง์ ํด์ฃผ์ด์ผ ํ๋ค.
- AppConfig์ @Bean ์ด ๋ถ์ ํด๋์ค๋ค์ ์คํ๋ง ์ปจํ ์ด๋์ ๋ด์์ ๊ด๋ฆฌํด์ค๋ค.
- ์คํ๋ง ์ปจํ
์ด๋๋ XML ๊ธฐ๋ฐ์ผ๋ก ๋ง๋ค ์๋ ์๊ณ , ์ ๋
ธํ
์ด์
๊ธฐ๋ฐ ์๋ฐ ์ค์ ํด๋์ค๋ก ๋ง๋ค ์ ์๋ค.
โป ์์ฆ์ xml๋ก ์ ์ฌ์ฉํ์ง ์๋๋ค. - AC.getBean("ํด๋์ค๋ช ", ํ์ );


- @Configuration
- @Bean
์คํ๋ง ๋น ๋ฑ๋ก
@Bean
- Bean ์ ๋ ธํ ์ด์ ์ด ๋ถ์ ํด๋์ค๋ค์ ์คํ๋ง ์ปจํ ์ด๋๊ฐ ๋น์ผ๋ก ๋ฑ๋กํ๋ค.
- ์ด ๋ ํจ์๋ช
๊ทธ๋๋ก ์ฌ์ฉํ๋ค.
- ๋น ์ด๋ฆ์ ์ง์ ํ ์๋ ์๋ค. @Bean(name="memberService2")
- โป๋น ์ด๋ฆ์ ํญ์ ๋ค๋ฅธ ์ด๋ฆ์ ๋ถ์ฌํด์ผ ํ๋ค.
- ๋น ์ด๋ฆ์ ์ง์ ํ ์๋ ์๋ค. @Bean(name="memberService2")
๐ก ์ปจํ ์ด๋์ ๋ฑ๋ก๋ ๋น ์กฐํํ ์คํธ ํด๋์์ ์คํํ๋ค.
โป ์ฐธ์กฐ : https://www.inflearn.com/roadmaps/373
๋ฐ์ํ
'๐ Spring > ๐ Spring Boot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [SpringBoot]BeanFactory์ ApplicationContext (0) | 2025.02.24 |
|---|---|
| [SpringBoot]์คํ๋ง ๋น ์กฐํ (0) | 2025.02.24 |
| [SpringBoot][Maven][RestAPI]MyBatis, JPA์ฌ์ฉํ๊ธฐ (0) | 2025.01.27 |
| [SpringBoot][RestAPI]Get/PostMapping(+json) (0) | 2025.01.26 |
| [SpringBoot][Maven][RestAPI]ํ๊ฒฝ์ค์ (์์กด์ฑ ์ถ๊ฐ-web, swagger, lombok) (0) | 2025.01.26 |
