JAVA AOP 报错error at ::0 can't find referenced pointcut pointCut02

使用aspectJ注解来实现Spring AOP,一下代码执行时报错error at ::0 can't find referenced pointcut pointCut02

@Component
@Aspect
public class 如何定义切点 {
	@Pointcut("execution(int com.shxt.service.ArithmeticService.add(int,int))")
	public void pointCut01(){}
	
	@Pointcut("execution(int com.shxt.service.ArithmeticService.sub(int,int))")
	public void pointCut02(){}
	
	@Before("pointCut02()")
	public void test01(){
		System.out.println("pointcut01,执行ADD时输出");
	}

}

原因在于引入的aspectjweaver.jar版本过低,替换为1.8.7版本后可正确运行。JDK环境为1.7时,应使用1.7.3及以上版本的aspectj的jar包。

jdk version spring version aspectjrt version and aspectjweaver version
1.6 3.0 + aspectjrt-1.6.2  and aspectjweaver-1.6.2
1.7 3.0 + aspectjrt-1.7.3 and aspectjweaver-1.7.3

以下为下载地址:

1.8.7版本aspectjweaver下载

猜你喜欢

转载自blog.csdn.net/sky_rabbit94/article/details/81122387