今天遇到了这样的情况!
public interface FlowService {
@FlowOperationLog
FlowDTO createFlow(FlowDTO flowDTO);
@FlowOperationLog
FlowDTO updateFlowStatus(FlowDTO flowDTO);
}
其中@FlowOperationLog
是flow类的日志注解,而我的大哥让我把该注解写在接口上,但我写上之后,发现该注解无法生效。
SO----->
- 注解只能加在具体的方法体上!
但有一个例外:
@PlanOperationLog
default T process(T t) {
preModify(t);
t = modify(t);
postModify(t);
return t;
}
当接口中的方法经过重新编排后,加了default
关键字,那么注解就可以生效!