非弹簧组件的弹簧 AOP [英] Spring AOP for non spring component

查看:32
本文介绍了非弹簧组件的弹簧 AOP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 java 配置编写 Spring 4 应用程序.我可以在这个项目中为所有 spring 组件使用 AOP.但是我不能将它用于普通的 POJO 类.

I am writing Spring 4 application with java config. I can use AOP in this project for all spring component. But i can't use it for a normal POJO class.

我需要添加什么库以及我需要在配置文件中放入什么配置才能使其正常工作

what is the library I need to add and what is the configuration I need to put in my config file to get this working

推荐答案

Spring AOP 只能应用于 Spring 管理的组件/beans,不能应用于非 Spring POJO.

Spring AOP can only be applied to Spring-managed components/beans, not to non-Spring POJOs.

如果要将 AOP 应用于非 Spring 类,则需要 AspectJ,而不是基于代理的AOP lite";Spring AOP 等框架.关于如何结合Spring使用AspectJ(完全不需要Spring)以及如何配置load-time weaving的更多信息,请阅读Spring 手册.

If you want to apply AOP to non-Spring classes you need AspectJ, not a proxy-based "AOP lite" framework like Spring AOP. For more information about how to use AspectJ (which does not need Spring at all) in combination with Spring and how to configure load-time weaving, please read the corresponding part of the Spring manual.

这篇关于非弹簧组件的弹簧 AOP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆