我尝试将方面用于可重复的操作。
我有以下方面配置:
@Aspect
@Component
public class TestInterceptor {
@Around("execution(public Map<Object, Object> controller.class.ContollerName+.*(..)) && this(self)")
public Object configureCommonResponse(ProceedingJoinPoint pjp, ControllerName self) throws Throwable {
return pjp.proceed();
}
}
此外,我还有一个控制器,其中包含我需要修改的方法:
@Controller
public class ControllerName {
@RequestMapping("/test")
public Map<Object, Object> test() {
....
}
}
然而,当我尝试调用test
方法时,我得到以下异常:
SEVERE: Servlet.service() for servlet [springServlet] in context with path [/test] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'controllerName': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.lang.Integer controller.pageSize; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'className' defined in URL [jar:file:/pathToJar.jar!/className/ClassName.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class className.ClassName]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given] with root cause
为什么要尝试为ClassName
类创建子类?我明确要求拦截controller.class.ContollerName
和子类中的执行,不是吗?