[英]Difference between @target and @annotation
In spring aop doc, it says: 在Spring aop doc中,它说:
@target - limits matching to join points (the execution of methods when using Spring AOP) where the class of the executing object has an annotation of the given type
@target - 限制匹配到连接点(使用Spring AOP时执行方法),其中执行对象的类具有给定类型的注释
@annotation - limits matching to join points where the subject of the join point (method being executed in Spring AOP) has the given annotation
@annotation - 限制连接点的匹配,其中连接点的主题(在Spring AOP中执行的方法)具有给定的注释
I think @target will match if the object has the given annotation like 我认为如果对象具有给定的注释,@ target将匹配
@MyAnnotation
public class Foo {}
while @annotation will match the annotation on method, like : 而@annotation将匹配方法的注释,如:
public class Foo {
@MyAnnotation
public void doSomething() {}
}
Is my understanding correct? 我的理解是否正确?
I opened this question based on this issue , wilkinsona gave the answer: 我根据这个问题打开了这个问题 , wilkinsona给出了答案:
The key difference is that @target matches the runtime type whereas @annotation matches the statically declared type.
关键区别在于@target与运行时类型匹配,而@annotation与静态声明的类型匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.