spring通过注解依赖注入和获取xml配置混合的方式
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配置混合的方式的更多相关文章
- Spring依赖注入:基于xml配置
基础接口 BeanFactory.ApplicationContext. BeanFactory用于创建并管理.获取各种类的对象. ApplicationContext从BeanFactory派生而来 ...
- spring 四种依赖注入方式以及注解注入方式
平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程 ...
- Spring Boot2(007):关于Spring beans、依赖注入 和 @SpringBootApplication 注解
一.关于Spring beans 和 依赖注入(Dependency Injection) spring boot 和 Spring 全家桶无缝衔接,开发过程中可以很轻松地使用 Spring 全家桶的 ...
- Spring Framework------>version4.3.5.RELAESE----->Reference Documentation学习心得----->Spring Framework的依赖注入和控制反转
Dependency Injection and Inversion of Control 1.概述: 1.1相关概念 bean:由IoC容器所管理的对象,也即各个类实例化所得对象都叫做bean 控制 ...
- spring六种种依赖注入方式
平常的java开发中,程序员在某个类中需要依赖其它类的方法,则通常是new一个依赖类再调用类实例的方法,这种开发存在的问题是new的类实例不好统一管理,spring提出了依赖注入的思想,即依赖类不由程 ...
- JavaEE开发之Spring中的依赖注入与AOP
上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...
- JavaEE开发之Spring中的依赖注入与AOP编程
上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...
- 谈谈自己了解的spring.NET的依赖注入
spring.net里实现了控制反转IOC(Inversion of control),也即依赖注入DI(Dependency Injection),以达到解耦的目的,实现模块的组件化.程序 ...
- Spring学习(三)——Spring中的依赖注入的方式
[前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring.不知 ...
随机推荐
- 页面d初始化加载
1.$(document).ready(function () { alert("Hello Word!"); }); 或简写为 2.$(function(){ alert(&qu ...
- java获取天气信息
通过天气信息接口获取天气信息,首先要给项目导入程序所需要的包,具体需要如下几个包: json-lib-2.4.jar ezmorph-1.0.6.jar commons-beanutils-1.8.3 ...
- struct和typedef struct的用法
我首先想到的去MSDN上看看sturct到底是什么东西,虽然平时都在用,但是每次用的时候都搞不清楚到底这两个东西有什么区别,既然微软有MSDN,我们为什么不好好利用呢,下面是摘自MSDN中的一段话: ...
- 信号量 sem_t 进程同步
sem_t分为有名和无名.有名的sem_t通过sem_open来创建, 而无名的sem_t通过sem_init的初始化. 用有名的sem_t来进程间同步是件很容易的事情,百度上一搜很多想相关的例子. ...
- Mahout
http://blog.csdn.net/yueyedeai/article/details/26567379
- 可以把一些常用的方法,写入js文件,引入html界面
这样,可以在多处应用.更好一些.缺点是不够灵活. 优点是,一处修改,多处应用. 函数这东西,一般都是先加载的,之后就可以随便调用了. function delquestion(obj){ //conf ...
- HashTable与HashMap使用总结
1.HashTable和HashMap比较 1)继承的父类不同. Hashtable继承自Dictionary类,而HashMap继承自AbstractMap类.但二者都实现了Map接口. publi ...
- Delphi 托盘程序实现 转
unit MainUnit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, F ...
- Number of Islands——LeetCode
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- Android新浪微博客户端(五)——主界面的TabHost和WeiboUtil
原文出自:方杰|http://fangjie.info/?p=183转载请注明出处 最终效果演示:http://fangjie.info/?page_id=54 该项目代码已经放到github:htt ...