【发布时间】:2015-08-18 15:11:15
【问题描述】:
我已经定义了一个自定义注释,如下所示。
package com.xyz;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Loggable {
String message() default "Log Message";
}
我的方面类包含以下方法:
@Around(value = "@annotation(com.xyz.Loggable)")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
// come code here
}
我的服务接口如下。
public interface Service {
@Loggable
public void method1();
}
我的实现如下。
public class ServiceImpl implements Service {
public void method1() {
// some code here
}
}
使用此设置,我的建议不会被触发。 (但是,如果我将 @Loggable 注释移动到 ServiceImpl 类中的 method1() 则会触发)。
我想保留在接口级别定义的注释而不是方法实现。有没有办法完成这项工作?
【问题讨论】:
标签: spring aspectj spring-annotations