码迷,mamicode.com
首页 > 编程语言 > 详细

spring bean 配置

时间:2014-12-18 22:04:31      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   io   color   os   sp   java   

<?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 配置

标签:style   blog   http   ar   io   color   os   sp   java   

原文地址:http://www.cnblogs.com/asnjudy/p/4172657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!