1.<context:property-placeholder/> :用于从外部属性文件中获取Bean的配置

<context:property-placeholder location="db.properties"></context:property-placeholder>
<bean class="com.mchange.v2.c3p0.ComboPooledDataSource" id="dataSource">
<property name="user" value="${user}"></property>
<property name="password" value="${password}"></property>
<property name="driverClass" value="${diverClass}"></property>
<property name="jdbcUrl" value="${jdbcUrl}"></property>
</bean>

2.SpEL的使用事例

<bean class="com.ddf.spring.beans.spel.Person" id="person">
<property name="name" value="汤姆"></property>
<!--引用其他bean的属性-->
<property name="city" value="#{address.city}"></property>
<!--引用其他对象-->
<property name="car" value="#{car}"></property>
<!--逻辑运算-->
<property name="info" value="#{car.price >= 300000 ? '金陵' : '白领'}"></property>
</bean>

3.配置bean的方法

<!--1.静态工厂方法-->
<bean id="car0"
class="com.ddf.spring.beans.factory.StaticCarFactory"
factory-method="getCar">
<constructor-arg value="奥迪"></constructor-arg>
</bean> <!--2.实例工厂方法-->
<bean class="com.ddf.spring.beans.factory.InstanceCarFactory" id="carFactory"></bean>
<bean id="car1" factory-bean="carFactory" factory-method="getCar">
<constructor-arg value="长安"></constructor-arg>
</bean>

4. exclude-filter 子节点指定排除哪些指定表达式的组件(assignable:类)

<context:component-scan
base-package="com.ddf.spring.beans.annotation">
<context:exclude-filter type="assignable"
expression="com.ddf.spring.beans.annotation.repository.UserRepository"/>
</context:component-scan>

5. include-filter 子节点指定排除哪些表达式的组件,需要配合use-default-filters使用(annotation)

<context:component-scan
base-package="com.ddf.spring.beans.annotation"
use-default-filters="false">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Repository"/>
</context:component-scan>

spring学习1的更多相关文章

  1. spring 学习之 bean 的注入方式 property和constructor-arg的使用方式

    spring 学习之 bean 的注入方式 property和constructor-arg的使用方式. bean的注入方式: property 注入是: 通过setxx方法注入. construct ...

  2. Spring学习之AOP总结帖

    AOP(面向方面编程),也可称为面向切面编程,是一种编程范式,提供从另一个角度来考虑程序结构从而完善面向对象编程(OOP). 在进行 OOP 开发时,都是基于对组件(比如类)进行开发,然后对组件进行组 ...

  3. Spring学习之第一个AOP程序

    IOC和AOP是Spring的两大基石,AOP(面向方面编程),也可称为面向切面编程,是一种编程范式,提供从另一个角度来考虑程序结构从而完善面向对象编程(OOP). 在进行 OOP 开发时,都是基于对 ...

  4. MyEclipse Spring 学习总结三 SpringMVC

    MyEclipse Spring 学习总结三 SpringMVC 一.SpringMVC原理 1.Springmvc 框架介绍 1)Spring 框架停工了构建Web应用程序的全功能MVC模块.Spr ...

  5. Spring学习 Ioc篇(一 )

    一直以来忙于项目的开发,Spring虽然不用,一直想系统地学习一下,想看看它的源码,都没有时间,这段时间比较充裕,就索性先把Spring学习下,熟悉各个功能再去探究它内部的实现.就从Ioc篇开始学习. ...

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

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

  7. Spring学习(二)——Spring中的AOP的初步理解[转]

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

  8. 【Spring学习笔记-MVC-3.1】SpringMVC返回Json数据-方式1-扩展

    <Spring学习笔记-MVC>系列文章,讲解返回json数据的文章共有3篇,分别为: [Spring学习笔记-MVC-3]SpringMVC返回Json数据-方式1:http://www ...

  9. Spring学习8-Spring事务管理

      http://blog.sina.com.cn/s/blog_7ffb8dd501014e0f.html   Spring学习8-Spring事务管理(注解式声明事务管理) 标签: spring注 ...

  10. Spring学习之Ioc控制反转(1)

    开始之前: 1. 本博文为原创,转载请注明出处 2. 作者非计算机科班出身,如有错误,请多指正 ---------------------------------------------------- ...

随机推荐

  1. TensorFlow中assign函数

    tf.assign assign ( ref , value , validate_shape = None , use_locking = None , name = None ) 定义在:tens ...

  2. 【转】@RequestBody注解出现的三点错误

    错误1 {     "timestamp": 1529747704259,     "status": 415,     "error": ...

  3. mod_conference ESL控制二(事件)

    根据上篇所述功能需求,esl需要处理以下几类事件: ESL_EVENT_CHANNEL_*  #channel相关事件,用户判断参会者是否应答.计费 DTMF事件 #识别参会者按键,根据按键进行操作( ...

  4. cocos2dx开发之util类&方法——取范围随机数

    #include <random> int random(int start, int end) { //return start+rand()%(end-start+1); static ...

  5. Restful架构学习

    Restful规范的架构是一种简洁并且面向资源的规范方式,其概念和起源大家google一下就好. 以下记录认识和搭建Restful规范的技术架构过程(入门级别),在网上发现了一张技术架构图很接近最初想 ...

  6. SQL-记录创建篇-006

    创建记录: 自己添加记录: insert into table_name values(12,'张三',22) , values(1,'王五',32) insert into table_name(n ...

  7. day45 jQuery

    在用js写代码时,会遇到一些问题: window.onload 事件有事件覆盖的问题,因此只能写一个事件. 代码容错性差. 浏览器兼容性问题. 书写很繁琐,代码量多. 代码很乱,各个页面到处都是. 动 ...

  8. python unittest setUp 和 setUpClass 区别

    import unittest class Test(unittest.TestCase): def setUp(self): print("start!=======") def ...

  9. Spark程序运行常见错误解决方法以及优化

    转载自:http://bigdata.51cto.com/art/201704/536499.htm Spark程序运行常见错误解决方法以及优化 task倾斜原因比较多,网络io,cpu,mem都有可 ...

  10. nginx 代理flask应用的uwsgi配置

    socket代理配置: 关于uwsgi的用法,请自行百度,这里只针对socket文件和端口的不同,进行单一的记录. 这种方式启动的flask应用,由于是通过socket与nginx通信的,所以必须制定 ...