概述 在Spring boot項目中,使用Aspectj實現AOP面向切面編程,以處理一些請求日志或者對某些方法進行一些監控的時候,報了【can't find referenced pointcut】的錯誤。
報錯信息如下:
Initialization of bean failed; nested exception is java.lang.IllegalArgu
mentException: error at ::0 can't find referenced pointcut executeController
環境 jdk 8;spring版本 4.0.0;maven 3.5.4。
報錯原因 spring AOP依賴jar版本過低。
解決方案 將aspectjweaver.jar替換較新的aspectjweaver-1.9.0.jar
在http://mavenrepository.com/ 搜aspectjweaver,找到:
<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.0</version> </dependency>
當然,更高版本的也可以。關於低版本jdk,網上搜到了一些對應aspectjweaver配置信息:
JDK1.6 ——aspectjweaver 1.6
JDK1.7 ——aspectjweaver 1.7.3+