spring error at ::0 can't find referenced pointcut解决办法

同一段代码,每个人都有不同的错误方式。
报错提示

Exception in thread "main" org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'userManager' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut allAddMethod
Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut 
allAddMethod   

第一:
百度出来网上出现此错误的通常原因:
原因定位到了aspectjweaver.jar包上,之前用的是aspectjweaver.jar包,把包更换为aspectjweaver-1.6.10.jar包之后就可以运行了。也就是jar的问题。
第二:
我遇到的问题:
在没有修改代码之前没有任何问题,通过aop已经把日志记录在数据库中了。说明我的问题不是jar出错,经过发现是我自己修改了切点,以及通知
我在修改中删除调了,一个没有使用的切点。但是其切点通知还在,也就是后置通知没有删除调。如下:

@Component
@Aspect
public class AroundAspect {
      public String id=null;   
      private  HttpServletRequest req ;
      @Autowired  
      LoginService logService; 
    //因为我后期修改为了人脸识别登陆,也就是这里的密码登陆没有使用,于是等效的我把切点就注释掉。
      /** 
       * 密码登录方法的切入点 
       */  
      @Pointcut("execution(* com.xihua.facedistinguish.action.*.login(..))")  
      public void loginCell(){}

//然而通知还在,就找不到切点了于是出现这个错误
     /** 
         * 密码登录操作(后置通知) 
         * @param joinPoint 
         * @param object 
         * @throws Throwable 
         */  
        @AfterReturning(value = "loginCell()", argNames = "object", returning = "object")  
        public void loginLog(JoinPoint joinPoint, Object object) throws Throwable {  
            JsonResult<User> js = (JsonResult<User>) object;
            User admin=js.getData();  
            if (admin==null) {  
                return;  
            }  
            if (joinPoint.getArgs() == null) {// 没有参数  
                return;  
            }  
            id=admin.getUser_idcard();  
            // 获取方法名  
            String methodName = joinPoint.getSignature().getName();  
            // 获取操作内容  
            String opContent = optionContent(joinPoint.getArgs(), methodName);  
            insertLog(opContent.getBytes("gbk").toString(), id, "密码登录"); 
        }  
}

通过发现这个问题,总结一句话,关联需同步解释。
欢迎交流学习,谢谢。

猜你喜欢

转载自blog.csdn.net/ljcc122/article/details/79982398