5

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

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

4 回答 4

5

这篇文章提示您需要升级到更新版本的 aspectj。在这里得到它

于 2013-10-28T12:32:26.813 回答
0

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

于 2014-12-30T10:49:48.703 回答
0

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

于 2014-01-25T22:27:42.600 回答
-1

问题是

com.mypackage.MyClass

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

于 2013-10-29T10:27:35.000 回答