Spring 2.5.6介绍(七)——自动装载constructo模式
package cn.csdn.service;public class AddressServiceImpl { private String address; public void setAddress(String address) { this.address = address; }}
package cn.csdn.service;public class EmpServiceImpl {private AddressServiceImpl addressServiceImpl ; public EmpServiceImpl(AddressServiceImpl addressServiceImp){this.addressServiceImpl = addressServiceImpl;}}
<?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-2.0.xsd"> <bean id="addressServiceImpl" scope="singleton" autowire="constructo "> </bean></beans>
?