首页 > 代码库 > spring bean 配置

spring bean 配置

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:p="http://www.springframework.org/schema/p"     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-3.2.xsd    ">    <bean id="car1" class="com.smart.Car">        <property name="brand">            <value><![CDATA[<font color="red">奥迪A6</font>]]></value>        </property>        <property name="color">            <value>红色</value>        </property>        <property name="maxSpeed">            <value>230</value>        </property>    </bean>    <bean id="car2" class="com.smart.Car">        <property name="brand" value="吉利" />        <property name="color" value="蓝色" />        <property name="maxSpeed" value="200" />    </bean>    <bean id="car3" class="com.smart.Car"         p:brand="红旗CA72"         p:color="黑色"         p:maxSpeed="200" />    <bean id="car4" class="com.smart.Car">        <constructor-arg index="0" type="java.lang.String" value="奥迪A6" />        <constructor-arg index="1" type="java.lang.String" value="白色" />        <constructor-arg index="2" type="int" value="250" />    </bean>    <bean id="boss1" class="com.smart.Boss">        <constructor-arg index="0" value="John" />        <constructor-arg index="1" ref="car1" />    </bean>    <bean id="boss2" class="com.smart.Boss">        <property name="name" value="Jack" />        <property name="car" ref="car1" />    </bean></beans>

 

spring bean 配置