Spring 2.5.6介绍(五)——自动装载byName模式
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 ;//属性名必须跟xml文件的AddressServiceImp bean的id名一致 public EmpServiceImpl(){}public void setAddressServiceImpl(AddressServiceImpl addressServiceImpl) {this.addressServiceImpl = addressServiceImpl;}public AddressServiceImpl getAddressServiceImpl() {return 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="byName"> </bean></beans>
?
?