[英]Which jar do I need to use Spring AOP AspectJ Annotation?
I'm new to Spring. 我是春天的新手。 I am trying to use Spring AOP annotation like the following code.
我试图使用Spring AOP注释,如下面的代码。
@Aspect
public class A {
@Pointcut("execution(* Operation.*(..))")
public void b(){}
@Before("b()")
public void c(JoinPoint jp)
{
System.out.println("a");
}
}
In my referenced libraries, I put all the spring jar (aop, core, aspects , beans, context, instrument, jdbc,jms,web, webmvc, etc) 在我引用的库中,我放了所有的spring jar (aop,core,aspects,beans,context,instrument,jdbc,jms,web,webmvc等)
I found another jar aspectj-1.9.3.jar and added it to my libraries in my eclipse . 我发现另一个jar aspectj-1.9.3.jar并在我的eclipse 中将它添加到我的库中。 However, I can't import
org.aspectj.lang.*
(which I need). 但是,我无法导入
org.aspectj.lang.*
(我需要)。 My Eclipse doesn't seem to locate it. 我的Eclipse似乎找不到它。
Did I find the right jar? 我找到了合适的罐子吗? (so the problem is something else?) Or do I need another jar?
(所以问题还有别的吗?)或者我需要另一个罐子吗? I am trying to do it without using Maven .
我试图不使用Maven 。
org.aspectj.lang.joinpoint is part of the aspectj tool library.
Add this to the Maven : 将其添加到Maven:
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.9</version>
</dependency>
Below i have mentioned the Lightweight jars as aspectjtools
is too big. 下面我提到了轻量级罐子,因为
aspectjtools
太大了。
compile group: 'org.springframework', name: 'spring-aop', version: '5.1.5.RELEASE'
compile group: 'aspectj', name: 'aspectjweaver', version: '1.5.4'
Size of jars: 罐子大小:
aspectjtools 1.9.2: 13.2 MB // too big
And 和
aspectjweaver 1.9.2: 2.0 MB, // too small as compared to aspectjtools jar
spring AOP 5.1.5: 360 KB
So, avoid using aspectjtools jar as it is too big. 所以,避免使用aspectjtools jar,因为它太大了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.