我的方面是:
@Aspect
@Service
public class MyAspect {
@AfterReturning(value="(execution(* find(..)) )" +
"&& target(com.erp.core.service.IBaseApplicationService) " +
"&& args(queryKey,object,..)")
public void print()
{
System.out.println("find method called");
}
}
AOP找不到的类型名称在:
@Transactional(readOnly=true)
public List find(String queryKey, Object[] object) {
return baseRepository.find(queryKey, object);
}
find是基本方法,因此每当我打开页面时都会调用它。
堆栈跟踪如下:
Caused by: java.lang.IllegalArgumentException: warning no match for this type name: queryKey [Xlint:invalidAbsoluteTypeName]
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:301)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:195)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:181)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:162)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
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:1426)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
它显示类型名称queryKey不匹配
最佳答案
在绑定形式中使用args时,需要在方法建议中包括要绑定的参数。
注意下面的方法声明
@AfterReturning(value="(execution(* find(..)) )" +
"&& target(com.erp.core.service.IBaseApplicationService) " +
"&& args(queryKey,object,..)",returning="returnList")
public void **print(String queryKey, Object[] object,List returnList)**
{
System.out.println("find method called");
}