简体   繁体   中英

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.

For instance, I would like to get a list of all methods annotated with @Bean in Spring Framework's source code or JARs.

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.

You can search for references in 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 .

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.

In STS , there is an option in search:

STS切入点匹配

in which you can specify for example: @target(org.springframework.stereotype.Service) which will find all the classes marked with @Service

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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