Spring①
来源:互联网 发布:java销售 编辑:程序博客网 时间:2024/06/09 15:55
1、spring解决了什么问题
类与类之间强耦合的问题
2、控制反转:一个对象依赖的其它对象会通过被动的方式传递进来,而不是这个对象自己创建或者查找依赖对象
3、注入方法:属性注入,需要为每一个依赖类创建相应的getter和setter方法。
构造方法注入,需要为依赖类创建相应的构造方法 。
内置对象:<property name="被注入的bean的名字" ref="被注入的类的beanId"></property>
自定义对象注入:<property name="email"><ref bean="emailid"/></property>
list注入:<property name="hobby"><list><value>读书</value><value>讨债</value></list></property>
scope:是否为单例,singleton单例 prototype非单例
@Repository:一般用于Dao的注入;@Service:一般用于Service层的注入;@Controller:一般用于Action层的注入。
AOP:对业务的辅助 嵌入业务完成一些功能
代理模式有权限控制是否调用真实的目标方法 装饰模式必须调用目标方法
AOPxml配置
<aop:config>
<aop:pointcut expression="execution(* com.*.*(..))" //包名-方法-参数 id="servicepointcut"/>
<aop:aspect ref="方法所在的类" ><aop:around method="方法名" pointcut-ref="切面id"/></aop:aspect>
<aop:pointcut expression="execution(* com.*.*(..))" //包名-方法-参数 id="servicepointcut"/>
<aop:aspect ref="方法所在的类" ><aop:around method="方法名" pointcut-ref="切面id"/></aop:aspect>
</aop:config>
0 0
- Spring①
- Spring入门①
- Spring
- Spring
- spring
- spring
- spring
- spring
- Spring
- spring
- spring
- Spring
- Spring
- spring
- Spring
- Spring
- spring
- spring
- 2017滴滴测试开发工程师
- excel导表给lua
- python挑战之level9
- redis命令学习之redis键
- 数据结构实验之链表七:单链表中重复元素的删除
- Spring①
- Linux shell Programming
- 机房收费系统之下机
- redis学习之Redis 字符串(String)
- HDU1874-畅通工程续(SPFA)
- UML
- 二分查找
- Leetcode 54 Spiral Matrix
- jquery事件绑定解绑机制源码分析