<!-- Car클래스의 setter를 이용해서 초기화 -->
<bean id="car" class="com.fastcampus.ch3.Car">
<property name="color" value="red"/>
<property name="oil" value="100"/>
<property name="engine" ref="engine"/>
<property name="doors">
<array value-type="com.fastcampus.ch3.Door">
<ref bean="door"/>
<ref bean="door"/>
</array>
</property>
</bean>
<bean id="engine" class="com.fastcampus.ch3.Engine" scope="singleton"/>
<bean id="door" class="com.fastcampus.ch3.Door" scope="prototype"/>
<!-- Car클래스의 생성자를 이용해서 초기화 -->
<bean id="car" class="com.fastcampus.ch3.Car">
<constructor-arg name="color" value="red"/>
<constructor-arg name="oil" value="100"/>
<constructor-arg name="engine" ref="engine"/>
<constructor-arg name="doors">
<array value-type="com.fastcampus.ch3.Door">
<ref bean="door"/>
<ref bean="door"/>
</array>
</constructor-arg>
</bean>
<bean id="engine" class="com.fastcampus.ch3.Engine" scope="singleton"/>
<bean id="door" class="com.fastcampus.ch3.Door" scope="prototype"/>
component-scan태그를 등록. 정규식을 추가했음.
<context:component-scan base-package="com.fastcampus.ch3">
<context:exclude-filter type="regex" expression="com.fastcampus.ch3.diCopy*.*"/>
</context:component-scan>