简体   繁体   English

Java AOP Spring框架

[英]java AOP spring framework

Is it possible to using Spring AOP advisor on a class that is not defined as a bean? 是否可以在未定义为bean的类上使用Spring AOP顾问程序?

I would like to use a before- and after-advice on a class that is not defined as a bean in spring.xml file. 我想在spring.xml文件中未定义为bean的类上使用前后建议。

Thanks in advance! 提前致谢!

As Rohit Jain already stated correctly, objects advised by Spring AOP aspects need to be Spring components. 正如Rohit Jain正确指出的那样,Spring AOP方面建议的对象必须是Spring组件。 But Spring also nicely plays with native AspectJ, as is described under Using AspectJ with Spring applications . 但是,Spring也可以很好地与本机AspectJ配合使用,如将AspectJ与Spring应用程序结合使用中所述。 With AspectJ you do not have any such limitations and can easily advise simple POJOs. 使用AspectJ,您没有任何此类限制,并且可以轻松建议简单的POJO。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM