标签:instance bean add res str bst ati pen frame
beans-relation.xml
<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--1. 抽象bean:bean的abstract属性为true的bean。这样bean不能被IOC容器实例化。仅仅能用来被继承。 2.若某一个bean的class属性没有指定,则该bean必须是一个抽象bean--> <bean id="address" p:city="Beijing" p:street="WuDaoKou" abstract="true"></bean> <!-- <bean id="address2" class="com.coslay.beans.autowire.Address" p:city="Beijing" p:street="DaZhongSi"></bean> --> <!--3.bean 配置的继承:使用bean 的parent 属性指定继承哪个baen的配置 --> <bean id="address2" class="com.coslay.beans.autowire.Address" parent="address"></bean> <bean id="address3" class="com.coslay.beans.autowire.Address" p:street="DaZhongSi" parent="address2"></bean> <bean id="car" class="com.coslay.beans.autowire.Car" p:brand="Audi" p:price="300000"></bean> <!--
使用depends-on配置依赖关系,car必须首先被执行,才能执行person --> <bean id="person" class="com.coslay.beans.autowire.Person" p:name="Tom" p:address-ref="address2" depends-on="car"></bean> </beans>
标签:instance bean add res str bst ati pen frame
原文地址:https://www.cnblogs.com/QYou/p/9646462.html