spring的xml配置文件中某个<bean></bean>中的property的用法是什么样的?

/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java

/spring-beans/src/test/resources/org/springframework/beans/factory/xml/collections.xml

void org.springframework.beans.factory.xml.XmlBeanCollectionTests.testRefSubelement() throws Exception

<bean id="jenny" class="org.springframework.tests.sample.beans.TestBean">
    <property name="name"><value>Jenny</value></property>
    <property name="age"><value>30</value></property>
    <property name="spouse">
    <!-- Could use id and href -->
        <ref local="david"/>
    </property>
</bean>

<bean id="david" class="org.springframework.tests.sample.beans.TestBean">
    <description>
        Simple bean, without any collections.这里是注释,spring不会解析
    </description>
    <property name="name">
        <description>The name of the user</description>
        <value>David</value>
    </property>
    <property name="age"><value>27</value></property>
</bean>

上面的蓝色属性值,spring通过set方法注入值。

org.springframework.tests.sample.beans.TestBean这个类里面必须有上面属性的get和set方法,比如

@Override
public int getAge() {
    return age;
}

@Override
public void setAge(int age) {
    this.age = age;
}

<property name="description"><value>Simple bean, without any collections.ok</value></property>

这种方法可以获取description的值。

spring通过注解依赖注入和获取xml配置混合的方式的更多相关文章

  1. Spring依赖注入:基于xml配置

    基础接口 BeanFactory.ApplicationContext. BeanFactory用于创建并管理.获取各种类的对象. ApplicationContext从BeanFactory派生而来 ...

  2. spring 四种依赖注入方式以及注解注入方式

    平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程 ...

  3. Spring Boot2(007):关于Spring beans、依赖注入 和 @SpringBootApplication 注解

    一.关于Spring beans 和 依赖注入(Dependency Injection) spring boot 和 Spring 全家桶无缝衔接,开发过程中可以很轻松地使用 Spring 全家桶的 ...

  4. Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework的依赖注入和控制反转

    Dependency Injection and Inversion of Control 1.概述: 1.1相关概念 bean:由IoC容器所管理的对象,也即各个类实例化所得对象都叫做bean 控制 ...

  5. spring六种种依赖注入方式

    平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程 ...

  6. JavaEE开发之Spring中的依赖注入与AOP

    上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...

  7. JavaEE开发之Spring中的依赖注入与AOP编程

    上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...

  8. 谈谈自己了解的spring.NET的依赖注入

         spring.net里实现了控制反转IOC(Inversion of control),也即依赖注入DI(Dependency Injection),以达到解耦的目的,实现模块的组件化.程序 ...

  9. Spring学习(三)——Spring中的依赖注入的方式

    [前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring.不知 ...

随机推荐

  1. 关于几种常用的Adapter使用区别

    Adapter常用的实现类如下: 1.ArrayAdapter:简单.易用的Adapter,通常用于将数组或List集合的多个值包装成多个列表项. 2.SimpleAdapter:并不简单.功能强大的 ...

  2. TCP回射服务器程序:main函数

    TCP回射并发服务器 1.创建套接字,绑定服务器的众所周知端口 创建一个TCP套接字,在待绑定到该TCP套接字的网际网套接字地址结构中填入通配地址(INADDR_ANY) 和服务器的众所知周(SERV ...

  3. 【JavaScript】关于JavaScript

    1. Language 2. DOM 3. Library 4. Framework

  4. Callback函数详解(我感觉,回掉函数的本质是函数指针,在业务做循环处理的时候,调用一下通知外部)

    2010年的最后一天了,转载一篇自己认为还不错的文章与大家分享.希望对大家有所帮助. 一,回调函数 我们经常在C++设计时通过使用回调函数可以使有些应用(如定时器事件回调处理.用回调函数记录某操作进度 ...

  5. Radar Installation 贪心

    Language: Default Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42 ...

  6. BZOJ 1022 [SHOI2008]小约翰的游戏John

    1022: [SHOI2008]小约翰的游戏John Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1635  Solved: 1036[Submit] ...

  7. delphi 通过控件的handle取得控件

    例子代码如下: vartsg:TstringGrid;begintsg:=Tstringgrid(FindControl(handle));//正常使用TstringGrid//tsg......./ ...

  8. 海美迪Q5智能机顶盒的蓝牙功能

    虽然在硬件上,海美迪Q5智能机顶盒没有集成蓝牙模块,但是在软件系统上,Q5是支持蓝牙驱动的,所以它可以通过USB外接蓝牙适配器来扩展出蓝牙功能,简单来说,就是你另外买个蓝牙适配器,插到Q5上面,就能用 ...

  9. js iframe问题

    父窗口获得iframe的window对象,从而控制对iframe的控制 document.getElementById("frameID").contentWindow;

  10. [LeetCode] 204. Count Primes 解题思路

    Count the number of prime numbers less than a non-negative number, n. 问题:找出所有小于 n 的素数. 题目很简洁,但是算法实现的 ...