spring学习知识点记录(待续)

spring学习知识点记录

一、依赖注入
1.命名空间:
beans、context、aop、tx、jms、jee、lang、mvc、oxm、util、Security、WebFlow、Dynamic
2.xml方式(需要在xml文件中配置bean,配置bean的属性)
a.基本类型:
Constructor-arg value ref
factory-method="getInstance"工厂单例模式
bean的生命周期:
singleton单例
prototype原型(每次创造一个新的对象)
request每次请求
session每次会话
global-session全局会话

初始化和销毁
init-method
destory-method
实现InitializingBean和DisposableBean接口
全局默认初始化和销毁
default-init-method
default-destory-method

property
value-String
rel-Object
b.集合
set<set><ref bean=""/></set>
list<list><ref bean=""/></list>
map<map><entry key-ref="" value-ref=""/><entry></map>
props<props><prop key="" value=""/></props>
c.表达式
基本类型表达式#{1}、#{'a'}、#{user.userName}
操作类#{T(java.lang.Math).PI},主要用来访问静态方法
基本运算表达式#{1+a}
正则表达式
筛选集合操作value=#{arr[1]}、 value=#{map['key']}、value=#{props['key']}、SystmEnvironment和SystemProperties value=#{SystemProperties['application.home']}
查询集合成员value=#{cities.?[population gt 10000]}大于10000的数组子集合结果 value=#{cities.^[population gt 10000]}第一个匹配 value=#{cities.$[population gt 10000]}最后一个匹配
投影集合value=#{cities.![name]} value=#{cities.![name+','+state]}


2.自动装配+xml+autowire注解方式(在xml文件中配置bean,由bean通过注解进行装配)
(Spring autowired+Qualifier,jdk Inject+Named,jdk Resource)
byName、byType(Primary、 autowire-candidate)、Constructor、autodetec)
3.自动检测方式+component注解方式(context:component-scan,Component、Service、Controller、Repository)
可以排除、可以包含<context:include-filter type="" expression=""/><context:exclude-filter type="" expression=""/>  (annotation、assignable、aspectj、custom、regex)
二.AOP
横切面、横切关注点
连接点、切点、切面、通知
切面是横切关注点的模块,比如日志服务、事务服务、安全服务
切点是切面的方法
连接点是程序的方法、属性等等,是所有可添加监听的点(所有可以发布事件的点)
切点是需要添加日志、事务、安全的点(具体发布事件的点)
切面就是采用的服务(监听类)
通知:before、after、round、finally、throw(一个事件类型,包括事件对象)
三.spring配置简写记录
<context:component-scan>自动检测
<mvc:annotation-driven>自动转换参数到对象
<context:annotation-config>自动装配

Spring得到Bean的两种方法
org.springframework.context.ApplicationContext(FileSystemXmlApplicationContext、XmlWebApplicationContext、ClasspathXmlApplicationContext)
org.springframework.beans.factory.BeanFactory

你可能感兴趣的:(spring学习知识点记录(待续))