java - 使用 Spring AOP 理解 AspectJ 风格

标签 java spring aop

<分区>

我正在阅读 spring documentation关于 AOP,现在我在关于使用 @AspectJ 样式的部分。

Spring AOP is implemented in pure Java. There is no need for a special compilation process. Spring AOP does not need to control the class loader hierarchy, and is thus suitable for use in a Servlet container or application server.

但是在关于@AspectJ风格的部分说

The @AspectJ support can be enabled with XML or Java style configuration. In either case you will also need to ensure that AspectJ’s aspectjweaver.jar library is on the classpath of your application (version 1.6.8 or later).

据我所知,aspectjweaver.jar 在编译时或加载时执行切面的实际编织。但是 Spring 有自己的基于代理的实现。所以我真的看不出任何依赖 aspectjweaver.jar 的原因。

没错,要使用@Aspect 注解我们需要aspectjrt 依赖。但是我不清楚对编织者的依赖。您不能简要解释一下它的实际工作原理吗?

最佳答案

Spring AOP 本身不使用 AspectJ 编织器,但它重用了 aspectjweaver.jar 文件中的一些类。它用于定义 AspectJ 风格的切入点表达式,例如@Before.

关于java - 使用 Spring AOP 理解 AspectJ 风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35427694/

相关文章:

Java - 创建多个对象后如何避免 StackOverflow?

java - 将 .class 转换为 .java

java - Dao 注册表重构

java - Spring getBean方法返回的那些bean从哪里来?

erlang - Elixir 编译时代码注入(inject)/AOP

java - Spring 3.0 : Unable to locate Spring NamespaceHandler for XML schema namespace

java - log4j配置与jboss7问题

java - 如何在 Spring 中模拟 ModelMapper?

java - Spring AOP : Xml vs AspectJ approach

java - 将字符串写入文本文件