非弹簧组件的弹簧AOP [英] Spring AOP for non spring component
问题描述
我正在用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 can only be applied to Spring-managed components/beans, not to non-Spring POJOs.
如果要将AOP应用于非Spring类,则需要AspectJ,而不是基于代理的"AOP lite".像Spring AOP这样的框架.有关如何将AspectJ(完全不需要Spring)与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屋!