简体   繁体   English

@target和@annotation之间的区别

[英]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.

相关问题 Ant - 任务和目标之间的区别 - Ant - difference between task and target 具有@JsonIgnore的属性与不具有注释的属性之间有什么区别? - What is the difference between a property with @JsonIgnore and one with no annotation? GWT生成器和Java注释处理器之间的区别? - Difference between a GWT Generator and a Java Annotation Processor? @RequestMapping注解中path和value属性的区别 - Difference between path and value attributes in @RequestMapping annotation felix scr中@Reference和@References批注之间的区别 - difference between @Reference & @References annotation in felix scr Hibernate映射文件和注解的区别 - Difference between Hibernate mapping file and annotation Guice 中作用域注解和作用域实例的区别 - The difference between a scoping annotation and scope instances in Guice 消息监听器和 jmslistener 注解有什么区别 - Whats the difference between message listeners and jmslistener annotation spring @Controller 和 @RestController 注解的区别 - Difference between spring @Controller and @RestController annotation Spring中的@PreAuthorize和@security批注有什么区别? - What is difference between @PreAuthorize and @security annotation in Spring?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM