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

3-22在同一个工场中注入Bean

2012-08-25 
3-22在同一个工厂中注入Bean使用ref指定要注入的值:?xml version1.0 encodingUTF-8?beans xmlns

3-22在同一个工厂中注入Bean
使用ref指定要注入的值:

<?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.xsd">    <bean id="encyclopedia" ref="encyclopedia"/>    </bean></beans>

使用bean的别名进行注入(name="knowitall"):
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xmlns:util="http://www.springframework.org/schema/util"       xsi:schemaLocation="                http://www.springframework.org/schema/beans                http://www.springframework.org/schema/beans/spring-beans.xsd                http://www.springframework.org/schema/util                http://www.springframework.org/schema/util/spring-util.xsd">    <bean id="encyclopedia"          name="knowitall"          value="13700000000"/>                <entry key="ConstantOfLife" value="326190476"/>            </util:map>        </constructor-arg>    </bean>    <bean id="oracle" ref="knowitall"/>    </bean></beans>

热点排行