简体   繁体   English

如何使用Eclipse IDE查找注释用法?

[英]How to find annotation usage using Eclipse IDE?

Using Eclipse IDE, I'd like to get a list of all "things" annotated with a specific Java annotation. 使用Eclipse IDE,我想获得一个用特定Java注释注释的所有“东西”的列表。

For instance, I would like to get a list of all methods annotated with @Bean in Spring Framework's source code or JARs. 例如,我想获得一个在Spring Framework的源代码或JAR中使用@Bean注释的所有方法的列表。

I'm aware that it's possible to look up annotation usage programmatically, as pointed out in this question . 我知道有可能以编程方式查找注释用法,正如本问题所指出的那样。 Instead I would like to look up annotation usage at development time within my Eclipse IDE. 相反,我想在Eclipse IDE中的开发时查找注释用法。

You can search for references in Eclipse. 您可以在Eclipse中搜索引用。 Click the annotation name, then right-click, select "References" and pick a scope for your search. 单击注释名称,然后右键单击,选择“引用”并为搜索选择范围。

You can Control-click on the annotation which will open the annotation definition class and then right-click and choose References -> Workspace . 您可以按住Control键并单击将打开注释定义类的注释,然后右键单击并选择“ References - >“ Workspace

EDIT: I just checked it, and it is enough to right-click on the mentioned annotation and choosing References -> Workspace without even going into its definition. 编辑:我刚检查过它,只需右键单击上面提到的注释并选择References - > Workspace即可,甚至无需进入其定义。

In STS , there is an option in search: STS中 ,搜索中有一个选项:

STS切入点匹配

in which you can specify for example: @target(org.springframework.stereotype.Service) which will find all the classes marked with @Service 您可以在其中指定: @target(org.springframework.stereotype.Service) ,它将找到标有@Service所有类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM