๋ฐ์ํ
- ์คํ๋ง ์ปจํ
์ด๋๋ ๋ค์ํ ํ์์ ์ค์ ์ ๋ณด๋ฅผ ๋ฐ์๋ค์ผ ์ ์๋ค.
- ์๋ฐ ์ฝ๋ AppConfig.class, xml, Groovy emd
- @์ ๋
ธํ
์ด์
๊ธฐ๋ฐ ์๋ฐ ์ฝ๋ ์ค์ ์ฌ์ฉ
- xml ์ค์
- ๋ ๊ฑฐ์ ํ๋ก์ ํธ ๋ค์์ ๋ง์ด ๋ณผ ์ ์๋ค.
- ์ฅ์ : ์ปดํ์ผ ์์ด ๋น ์ค์ ์ ๋ณด๋ฅผ ์ฌ์ฉํ ์ ์๋ค.
- appConfig.xml ๋ง๋ค๊ธฐ
- ์ฝ๋๋๋ณด๊ธฐโป ref๋ reference์ ์ค์ ๋ง๋ก ์ฐธ์กฐํ๋ค๋ ๋ป์ด๋ค.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="memberService" class="hello.core.member.MemberServiceImpl"> <constructor-arg name="memberRepository" ref="memberRepository"/> </bean> <bean id="memberRepository" class="hello.core.member.MemoryMemberRepository"/> <bean id="orderService" class="hello.core.order.OrderServiceImpl"> <constructor-arg name="memberRepository" ref="memberRepository"/> <constructor-arg name="discountPolicy" ref="discountPolicy"/> </bean> <bean id="discountPolicy" class="hello.core.discount.RateDiscountPolicy"/> </beans>
๊ทธ๋์ ref์ ๋ค์ด๊ฐ ์ด๋ฆ๋ค์ ๋ฐ๋ก <bean />์ผ๋ก ๋ง๋ค์ด ๋ ๊ฒ์ด๋ค. - ํ
์คํธ
- ๋ ๊ฑฐ์ ํ๋ก์ ํธ ๋ค์์ ๋ง์ด ๋ณผ ์ ์๋ค.
โป ์ฐธ์กฐ : https://www.inflearn.com/roadmaps/373
๋ฐ์ํ
'๐ Spring > ๐ Spring Boot' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SpringBoot]์ฑ๊ธํค ์ปจํ ์ด๋ (0) | 2025.02.24 |
---|---|
[SpringBoot]BeanDefinition (0) | 2025.02.24 |
[SpringBoot]BeanFactory์ ApplicationContext (0) | 2025.02.24 |
[SpringBoot]์คํ๋ง ๋น ์กฐํ (0) | 2025.02.24 |
[SpringBoot]์คํ๋ง์ผ๋ก ์ ํ (1) | 2025.02.20 |