<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
<u>xmlns:context="http://www.springframework.org/schema/context"</u>
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
<u>http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd </u>
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- <bean id="animal" class="ioc.Animal">
<property name="animalType">
<value>Dog</value>
</property>
<property name="moveMode">
<value>fly</value>
</property>
</bean> -->
<context:annotation-config/>
<bean id="movePrinter" class="ioc.ScreenPrinter"></bean>
<bean id="animal" class="ioc.Animal">
<!-- <property name="printer" ref="movePrinter"></property> -->
<!-- 1、自动装配 -->
<!-- 2、使用注解来自动装配 -->
<property name="animalType">
<value>Dog</value>
</property>
<property name="moveMode">
<value>fly</value>
</property>
</bean>
<!-- <bean id="animal" class="ioc.Animal">
<constructor-arg index="0" type="java.lang.String" value="Bird"></constructor-arg>
<constructor-arg index="1" type="java.lang.String" value="fly"></constructor-arg>
</bean> -->
</beans>
下划线标注的行很重要,解决问题的关键!