我在aspectJ中有这样的表达:
@Pointcut("within(com.param.cpms.dao.impl.ProjectMetaDaoImpl)")
public void daoExceptionHandle() {
}
在Spring 3.0启动时,我收到以下错误:
nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
我在aspectJ中有这样的表达:
@Pointcut("within(com.param.cpms.dao.impl.ProjectMetaDaoImpl)")
public void daoExceptionHandle() {
}
在Spring 3.0启动时,我收到以下错误:
nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
可能问题不在于您的切入点,而在于使用该切入点和使用切入点中不存在的参数的建议。只需从建议中删除参数(好吧,或者将其添加到切入点)。
它是 Joinpoint ("p 小写)
org.aopalliance.intercept.Joinpoint;
更改为 JointPoint("P 大写)
org.aspectj.lang.JoinPoint;
该帖子相当陈旧,但为了完整起见,如果您使用@Around 建议,我会添加另一个原因。
根据Spring AspectJ 文档,建议的第一个参数必须是 ProceedingJoinPoint。如果它丢失,您将收到此异常消息。可悲的是,该异常并不指向错误的建议,因此解决该错误是一个偶然的机会。
由于类的错误导入,我得到了这个错误。我应该导入 import org.aspectj.lang.JoinPoint class ,而是从不同的包中导入了一些其他的 Joinpoint 类。
我遇到了同样的错误,在我的场景中我使用了两个方法参数
public void methodName(JoinPoint joinPoint ,HttpServletRequest request) throws
我的注释就像
@Before("execution(public * com.java.controller.*Controller.*(..))")
作为解决方案,我添加了
参数(请求,..)
@Before("execution(public * com.java.controller.*Controller.*(..)) && args(request,..)")
有时原因可能是这个。
public void afterReturning(JoinPoint joinPoint, Object result)
Object result
只需按如下方式删除,它就对我有用。
public void afterReturning(JoinPoint joinPoint)
我也有这个问题,在我的情况下,这是一个错误的导入:org.aopalliance.intercept.Joinpoint;
它需要是:org.aspectj.lang.JoinPoint;
切入点异常中的正式未绑定也发生在 AOP 中的两个响应中。
原因一:如果在返回通知后没有返回语句
对于基于 XML 的实现
<aop:aspect id="myaspect" ref="trackAspect">
<aop:pointcut id="pointCutAfterReturning" expression="execution(* com.springlearn.Operation.*(..))" />
<aop:after-returning method="myAdvice" returning="result" pointcut-ref="pointCutAfterReturning"/> //Make sure returning result is added
</aop:aspect>
对于基于注释的实现
@AfterReturning(
pointcut = "execution(* Operation.*(..))",
returning= "result") //Make sure returning result is added
原因2:如果没有投掷后投掷建议
对于基于 XML 的实现
<aop:aspect id="myaspect" ref="trackAspect" >
<!-- @AfterThrowing -->
<aop:pointcut id="pointCutAfterThrowing" expression="execution(* com.javatpoint.Operation.*(..))" />
<aop:after-throwing method="myadvice" throwing="error" pointcut-ref="pointCutAfterThrowing" /> //Make sure throwing error is added
</aop:aspect>
对于基于注释的实现
@AfterThrowing(
pointcut = "execution(* Operation.*(..))",
throwing= "error") //Make sure throwing error is added
如果您使用的是基于 XML 的配置并且您的配置是这样的:
<aop:config>
<aop:aspect ref="bAdvice">
<aop:pointcut id="displayPointcut" expression="execution(* com.example.demo.BusinessClass.display())"/>
<aop:before method="before" pointcut-ref="displayPointcut" />
</aop:aspect>
</aop:config>
然后在 2 种情况下,您会收到错误消息:
最终当 XML 中定义的方法参数与实际方法不匹配时,就会出现这个错误。
这不是您的回答,但可能会对您有所帮助。
Spring AOP 教程你可以参考这个教程
@Before("execution(* com.de.controller..*(..))")
public void beforeLoggerAdvice(JoinPoint joinPoint, WebRequest request) {
DeUtil.looger.info("--working");
}
我得到了相同的异常,但是由于WebRequest,我删除了它并使用了替代方法
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();