我试图捕获覆盖spring的验证方法后发出的所有错误。
我收到以下错误
Pointcut is not well-formed: expecting ')' at character position 135
我尝试了很多组合,例如在前后放置“)”并删除,但仍然出现相同的错误。我正在学习 Spring,所以不确定这是否正是实现 aop 的方法。有谁能告诉我哪里错或纠正我
这是实现验证方法的类
package com.myapplication.validations
public class MyValidate implements Validator{{
public boolean supports(Class<?> clazz) {
return MyValidate.class.equals(clazz);
}
public void validate(Object target, MyApplicationErrors errors) {
//all validations
}
}
现在在我的 spring application-context.xml 中,我编写了以下 aop
<aop:aspectj-autoproxy />
<bean id="captureErrors"
class="com.myapplication.aop.CaptureAllErrors" />
<aop:aspect ref="captureErrors">
<aop:pointcut id="magicallyCaptureErrors"
expression="execution(* com.myapplication.validations.MyValidate.validate(Object, com.myapplication.allerrors.MyApplicationErrors )) and args(Object target, com.myapplication.allerrors.MyApplicationErrors errors)" />
<aop:after-returning pointcut-ref="magicallyCaptureErrors" method="getAllErrors"/>
</aop:aspect>
</aop:config>
我的捕获所有错误类如下
package com.myapplication.aop
@Aspect
@Component
public class CaptureAllErrors {
public void getAllErrors(Object target, com.myapplication.allerrors.MyApplicationErrors errors){
log.info(errors.toString());
}
}