首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Spring 2.5.6引见(五)——自动装载byName模式

2012-08-21 
Spring 2.5.6介绍(五)——自动装载byName模式package cn.csdn.servicepublic class AddressServiceImpl {pr

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>

?

?

热点排行