Spring 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:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <bean id="User" class="com.war.spr.User">
        <property name="id" value="22"></property>
        <property name="name" value="username"></property>
        <property name="age" value="22"/>
        <!--使用ref进行引用注入-->
        <property name="cname" ref="child"></property>
    </bean>
    <bean id="child" class="com.war.spr.Child">
        <property name="cname" value="22"></property>
        <property name="cage" value="username"></property>
    </bean>
</beans>

注解

posted @ 2017-06-20 11:00  Mu_gua  阅读(136)  评论(0编辑  收藏  举报