【发布时间】:2015-11-23 20:21:03
【问题描述】:
我正在尝试在 Spring 启动应用程序(使用 Spring 安全性)中使用 AOP 记录控制器方法,但无法成功。添加方面相关代码后,它没有返回任何异常并且处理程序方法无法检测到:
控制器方法:
@RequestMapping(value="/index", method = RequestMethod.GET)
public ModelAndView welcome() {
ModelAndView modelView = new ModelAndView();
modelView.setViewName("index");
return modelView;
}
方面:
@Pointcut("within(@org.springframework.web.bind.annotation.RequestMapping *)")
public void requestMapping() {}
@Around("execution(* com.hms.controllers.HomeController.*(..)) && @annotation(requestMapping)")
public void aroundControllerMethod(ProceedingJoinPoint joinPoint, RequestMapping requestMapping) {
System.out.println("Testing aroundController: " + joinPoint.getSignature().getName());
}
以下日志失败:
2015-11-18 12:57:41.310 DEBUG 6180 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /index
2015-11-18 12:57:41.310 DEBUG 6180 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/index]
如果 Aspect 相关代码被注释,索引页面返回没有任何问题
有什么见解吗?
【问题讨论】:
标签: java spring-security spring-boot spring-aop