我正在学习春天的AOP。在尝试一个例子的时候,我得到的是“Pointcut没有格式良好”的例外。以下是例外情况:
代码: 包org.aspectDemo.aspect.com;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class LogginAspect {
@Before("allGetters()")
public void LoggingAdvice(){
System.out.println("Advice run. Get method called");
}
@Pointcut("execution(* * org.aspectDemo.model.com.Circle.*())")
public void allGetters(){}
}
例外:
java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting '(' at character position 14
execution(* * org.aspectDemo.model.com.Circle.*())
^^^
at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:316)
at org.aspectj.weaver.reflect.InternalUseOnlyPointcutParser.resolvePointcutExpression(InternalUseOnlyPointcutParser.java:36)
at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.getDeclaredPointcuts(Java15ReflectionBasedReferenceTypeDelegate.java:309)
at org.aspectj.weaver.ReferenceType.getDeclaredPointcuts(ReferenceType.java:884)
at org.aspectj.weaver.ResolvedType$PointcutGetter.get(ResolvedType.java:243)
at org.aspectj.weaver.ResolvedType$PointcutGetter.get(ResolvedType.java:241)
at org.aspectj.weaver.Iterators$4$1.hasNext(Iterators.java:213)
at org.aspectj.weaver.Iterators$4.hasNext(Iterators.java:230)
at org.aspectj.weaver.ResolvedType.findPointcut(ResolvedType.java:743)
at org.aspectj.weaver.patterns.ReferencePointcut.resolveBindings(ReferencePointcut.java:148)
at org.aspectj.weaver.patterns.Pointcut.resolve(Pointcut.java:189)
at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:313)
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:294)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:212)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:199)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:188)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:168)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:208)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:262)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:294)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:118)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:88)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:69)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:372)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:335)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:421)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1558)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
... 11 more
答案 0 :(得分:2)
根据the documentation,你似乎有太多的星号。此外,"任何参数"编码为(..)
您的表达式应为
execution(* org.aspectDemo.model.com.Circle.*(..))