我需要使用spring-aop拦截带注释的方法。 我已经有了拦截器,它实现了AOP联盟的MethodInterceptor。使用Spring @Configuration和MethodInterceptor拦截带注释的方法
下面是代码:
@Configuration
public class MyConfiguration {
// ...
@Bean
public MyInterceptor myInterceptor() {
return new MyInterceptor();
}
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
// ...
}
public class MyInterceptor implements MethodInterceptor {
// ...
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
//does some stuff
}
}
从我一直在读它曾经是我可以用一个@SpringAdvice批注指定当拦截器拦截要的东西,但不再存在。
任何人都可以帮助我吗?
非常感谢!
卢卡斯