spring学习1
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的更多相关文章
- spring 学习之 bean 的注入方式 property和constructor-arg的使用方式
spring 学习之 bean 的注入方式 property和constructor-arg的使用方式. bean的注入方式: property 注入是: 通过setxx方法注入. construct ...
- Spring学习之AOP总结帖
AOP(面向方面编程),也可称为面向切面编程,是一种编程范式,提供从另一个角度来考虑程序结构从而完善面向对象编程(OOP). 在进行 OOP 开发时,都是基于对组件(比如类)进行开发,然后对组件进行组 ...
- Spring学习之第一个AOP程序
IOC和AOP是Spring的两大基石,AOP(面向方面编程),也可称为面向切面编程,是一种编程范式,提供从另一个角度来考虑程序结构从而完善面向对象编程(OOP). 在进行 OOP 开发时,都是基于对 ...
- MyEclipse Spring 学习总结三 SpringMVC
MyEclipse Spring 学习总结三 SpringMVC 一.SpringMVC原理 1.Springmvc 框架介绍 1)Spring 框架停工了构建Web应用程序的全功能MVC模块.Spr ...
- Spring学习 Ioc篇(一 )
一直以来忙于项目的开发,Spring虽然不用,一直想系统地学习一下,想看看它的源码,都没有时间,这段时间比较充裕,就索性先把Spring学习下,熟悉各个功能再去探究它内部的实现.就从Ioc篇开始学习. ...
- Spring学习(三)——Spring中的依赖注入的方式
[前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring.不知 ...
- Spring学习(二)——Spring中的AOP的初步理解[转]
[前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring. ...
- 【Spring学习笔记-MVC-3.1】SpringMVC返回Json数据-方式1-扩展
<Spring学习笔记-MVC>系列文章,讲解返回json数据的文章共有3篇,分别为: [Spring学习笔记-MVC-3]SpringMVC返回Json数据-方式1:http://www ...
- Spring学习8-Spring事务管理
http://blog.sina.com.cn/s/blog_7ffb8dd501014e0f.html Spring学习8-Spring事务管理(注解式声明事务管理) 标签: spring注 ...
- Spring学习之Ioc控制反转(1)
开始之前: 1. 本博文为原创,转载请注明出处 2. 作者非计算机科班出身,如有错误,请多指正 ---------------------------------------------------- ...
随机推荐
- vue学习笔记 - 篇2
1.借助Vue.extend()方法创建组件 注意点 var Aaa = Vue.extend({ template: "<h1>这是标题</h1>" }) ...
- 在Fiddler中添加自己所需的显示列
有时候我们想了解请求响应的时间.服务器IP等相关信息,Fiddler默认是没有显示的,这个时候就需要我们借助高级用法---自定义显示列, 其实主要就是操作这个文件Fiddler2\Scripts\Cu ...
- javascript性能优化之避免二次评估
Javascript与许多脚本语言一样,允许你在程序中获取一个包含代码的字符串然后运行它,有多种方式可以实现在一串Javascript代码并运行它. 代码示例如下 <html> <h ...
- CSS 隐藏ul
老师要求只能用css做出覆盖ul时显示ul,之前一直在试 [ display:none display:block ]后来发现一直是闪烁的状态 不能实现消失 然后就试用了透明度,一下就可以了 ...
- swift3.0自定义相机界面
这是公司上上上一个项目的自定义相机界面,原来是swift2.0写的,今天改为swift3.0,记录一下. 效果图如下: ...
- myelipse与maven结合配置
添加插件 指定maven中jar包默认仓库地址 maven中debug模式中断点关联不到项目代码的问题 解决方法参考文章:https://blog.csdn.net/urnot/article/det ...
- C# 利用反射完成计算器可扩展功能
一个主要的窗体程序,两个输入框,一个label using System; using System.Collections.Generic; using System.ComponentModel; ...
- oracle-pl/sql之三
集合与记录 set serveroutput on create or replace package my_types authid definer is type my_rec is record ...
- CANVAS笔记
bglayer.add(bgimage) /*后面的层会覆盖前面的,所以要放在上面的,就要后面才添加!*/ bglayer.add(this.shape1) Layer.destroy() layer ...
- 修改linux服务器的MySQL密码
1. 首先用管理员权限登陆Linux: 2. 输入:vi /etc/my.cnf 回车.然后按“i”键盘,在这个文件中的最后一行输入:skip-grant-tables 然后按 esc ...