Spring_Spring常见错误_error at ::0 can't find referenced pointcut解决办法

原址 http://blog.sina.com.cn/s/blog_9ecb0d9d0101fheg.html


Spring中采用annotation的方式实现AOP代理,运行测试代码时抛出以下异常:
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.IllegalArgumentExceptionerror at ::0 can't find referenced pointcut  
allAddMethod                  
at org.aspectj.weaver.tools.PointcutParser.parsePointcutexpression_r(PointcutParser.java:315)
at  org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression
            (AspectJExpressionPointcut.java:189)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch
            (AspectJExpressionPointcut.java:176)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter
            (AspectJExpressionPointcut.java:157)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:189)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:244)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:278)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
            .findEligibleAdvisors (AbstractAdvisorAutoProxyCreator.java:83)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator
             .getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator
            .postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
           .applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:313)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
           .initializeBean(AbstractAutowireCapableBeanFactory.java:1181)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
            .createBean(AbstractAutowireCapableBeanFactory.java:427)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
            (AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton
            (DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
            (AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
            (AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory
            .preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh
            (AbstractApplicationContext.java:352)
at org.springframework.context.support.ClassPathXmlApplicationContext.                                          (ClassPathXmlApplicationContext.java:122)
at org.springframework.context.support.ClassPathXmlApplicationContext.                                          (ClassPathXmlApplicationContext.java:66)
at com.huang.spring.Client.main(Client.java:10)
 
       本人详细检查过代码和applicationContext.xml配置文件,发现并没有错!而其他Spring项目能运行,因此出错原因可以肯定是aspectj两个jar包的问题。网上很多说法是spring 2.0的版本中的的aspectjrt.jar和jdk不兼容,好吧,本人的JDK是1.7的,于是尝试使用不同版本的aspectjrt.jar文件,发现错误仍然存在!所以不是aspectjrt.jar的问题。
       于是本人下载了最新版本的aspectjweaver.jar并替换了原来的版本,error at ::0 can't find referenced pointcut allAddMethod成功解决了,程序正常运行。

你可能感兴趣的:(JavaEE_Spring)