【发布时间】:2015-07-09 03:49:16
【问题描述】:
当我使用spring boot时,aop无法与注解控制器一起使用,我怎样才能最好地做到这一点?
@Aspect
@Component
@Configuration
public class MethodStatisticsPointcutAspect {
@Resource
private CounterService counterService;
// aop defined
@Around("@annotation(com.xxx.xxx.metrics.annotation.MethodStatistics)")
private void around(ProceedingJoinPoint pjp) {
// do sth
}
}
我的控制器是这样定义的:
@RestController
@RequestMapping("/usertest")
public class UserTestController {
@RequestMapping("/test")
@MethodStatistics
String test() {
// do sth
}
}
我希望所有带有注解@MethodStatistics的方法都使用aop manager,但是它根本无法使用@controller~
【问题讨论】:
-
欢迎来到Stack Overflow。我不确定你的问题是什么,也不确定你有什么问题。
标签: java controller spring-boot