找不到引用的切入点

时间:2013-10-28 11:20:04

标签: spring aspectj spring-aop

我正在开发我的第一个方面,我遇到了以下麻烦。

MyAspect类:

@Component
@Aspect
public class MyAspect{


@Pointcut("execution(* com.mypackage.MyClass.method(..))")
public void sendComunication(){}

@AfterReturning("sendComunication()")
public void sendComunicationMail() {

    //TODO somethings
}

}

然后我在applicationContext中添加了“aop:aspectj-autoproxy”和aop名称空间。现在,当我尝试构建我的应用程序时,我收到此错误:

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut sendComunication
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    ... 36 more
Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut sendComunication
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:315)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:193)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:182)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:163)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:210)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:264)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:296)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 42 more

我在哪里做错了?

4 个答案:

答案 0 :(得分:5)

This post暗示您需要升级到aspectj的更新版本。 Get it here

答案 1 :(得分:0)

无论你提到什么,都无法找到方面(即“执行(* com.mypackage.MyClass.method(...))”)。方法签名可能是错误的。

答案 2 :(得分:0)

我最近遇到了同样的问题。答案是将我们的aspectj版本更改为新版本。就像 Sotirios Delimanolis 所说的那样。

答案 3 :(得分:-1)

问题在于

  

com.mypackage.MyClass

不是一个管理到Spring的bean,而是它是vaadin面板中的一个方法