一、Set注入
<bean id="userDao" class="com.finnlee.daoImpl.UserDaoImpl" scope="prototype" ></bean> //name="userDao"是属性 ref="userDao" 是引用上面bean对象 <bean id="userService" class="com.itheima.service.impl.UserServiceImpl"> <property name="userDao" ref="userDao"/> //Set注入
<constructor-arg name="userDao" ref="userDao"></constructor-arg> //构造方法注入
</bean> xmlns:p="http://www.springframework.org/schema/p" <bean id="userService" class="com.itheima.service.impl.UserServiceImpl" p:userDao-ref="userDao"/>