Spring使用@Aspect
注解在启动项目时出现 NoClassDefFoundError,一般出现 NoClassDefFoundError 都是缺少Maven依赖,排查思路一般是检查pom.xml
文件
查了一下,要使用@Aspect
注解需要引入外部的Maven依赖为:
<!-- Spring使用Aspect依赖的jar包 start-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<!-- Spring使用Aspect依赖的jar包 end-->
上面依赖省略了依赖的version
是因为本人采用了继承的方式继承了父类的Maven工程,所以没有version这个节点,如果需要复制博主的Maven依赖请自行加上version
以下是添加了Maven依赖后项目中External Libraries中有的jar包