在一个Swing的项目中,每个控制用户操作的action都是用new出来的,所以还要手动set一些被spring管理的对象。
后来实在受不了这些冗余的代码了,写代码的时候有时候又可能会把spring的对象跟非spring的对象顺序弄乱了,让代码结构不清晰,在spring2的介绍中,听说它连new出来的对象都可以管理,便去下了spring rc3来,布署到项目中。
研究了半天,才发现其实是很容易的事,可怜我们看文档看了半天。
1。虚拟机加个参数:-javaagent:lib/aspectjweaver.jar(后面是spring带的aspectjweaver.jar的路径)
2。在spring配置文件里面加:
xml 代码
<aop:spring-configured><aop:spring-configured>
3。在要被管理的类中加上annotation:
java 代码
- @Configurable(autowire = Autowire.BY_TYPE)
autowire应该不用说了。
</aop:spring-configured> </aop:spring-configured>
分享到:
- 2006-11-26 10:45
- 浏览 1164
- 评论(0)
- 论坛回复 / 浏览 (0 / 1688)
- 查看更多
相关推荐
Spring AOP的AspectJ支持jar包; 包括: com.springsource.net.sf.cglib-2.2.0.jar com.srpingsource.org.aopalliance-1.0.0.jar com.srpingsource.org.aspectj.weaver-1.68.RELEASE.jar
要在 Spring 应用中使用 AspectJ 注解, 必须在 classpath 下包含 AspectJ 类库: aopalliance.jar、aspectj.weaver.jar 和 spring-aspects.jar等jar包,文件已打包上传。
spring aspectj aspectrt.jar
spring通过aspectj来实现事务控制
NULL 博文链接:https://rain1109.iteye.com/blog/1838100
spring5基于aspectj实现aop操作所需jar包 com.springsource.net.sf.cglib-2.2.0.jar com.springsource.org.aopalliance-1.0.ar com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar spring-aspects-5.2.6....
以公司订单管理的模型为例(大部分步骤和业务了逻辑已经删除,只保存AOP注解这一部分)Spring AOP
AspectJ shows its real power when combined with Spring. This new edition focuses on Spring-AspectJ integration, which is a major feature of Spring 2.5. Readers will find this edition immensely helpful...
Spring4 In Action-4.2-@AspectJ-切面,Spring4 In Action-4.2-@AspectJ-切面。Spring4 In Action-4.2-@AspectJ-切面
aspectj
Spring 使用AspectJ 实现 AOP之前置通知小例子,实际跑过,验证可信。
主要对Spring AOP的相关概念和简单的静态代理、动态代理以及常见的几种AOP配置方式做总结学习。主要包括:1. AOP的常见概念 2. 静态代理 3. jdk动态代理 4. Aspectj and Aspectjweaver 5. **aop-config** 6. CGLIB ...
NULL 博文链接:https://fei-xiang.iteye.com/blog/521637
这是进行spring-framework的AOP开发时需要的jar包,解压缩其中lib文件夹,lib文件夹中有4个重要的jar包:aspectjrt.jar,aspectjtools.jar,aspectjweaver.jar,org.aspectj.matcher.jar,解压缩后把这4个jar包导入...
Spring 使用AspectJ 实现 AOP(基于xml文件、基于注解)
spring和aspectj的aop实验,详细内容可以移步至博客:https://mp.csdn.net/postedit/97750888
NULL 博文链接:https://tuoxinquyu.iteye.com/blog/1465187
Spring AOP之基于AspectJ注解总结与案例 ,具体效果和过程看博文 http://blog.csdn.net/evankaka/article/details/45394409
Spring4.3.7的AOP依赖包-AspectJ
Spring 中基于 AOP 的 XML架构 所需要的jar文件. 网上找不到的同学可以在...包括 aspectj-1.8.13.jar & aspectjrt-1.8.0.RELEASE.jar & aspectjweaver-1.8.0.RELEASE.jar & spring-aopalliance-1.0.jar四个jar文件.