与设值注入有以下不同,颜色标出

package com.ij34.web;
import com.ij34.servce.people;
import com.ij34.servce.root; public class chinese implements people{
private root dog; public root getDog() {
return dog;
} /* public void setDog(root dog) {
this.dog = dog;
}*/
public chinese(root dog) {
this.dog = dog;
}
@Override
public void cut() {
// TODO Auto-generated method stub
System.out.println("我是中国人");
System.out.println(dog.chop());
} }

<?xml version="1.0" encoding="GBK"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd"> <bean id="chinese" class="com.ij34.web.chinese">
<!-- <property name="dog" ref="iron"></property>
-->
<constructor-arg ref="iron" type="com.ij34.servce.root"></constructor-arg>
</bean>
<bean id="stone" class="com.ij34.web.stonechop"></bean>
<bean id="iron" class="com.ij34.web.ironchop"></bean>
</beans>

spring4笔记----spring4构造注入-LMLPHP

05-04 11:42