简体   繁体   中英

How to scan for Annotations and the values assigned to them Using Spring

I want to scan for @Controller @Path etc other annotations in my application (Controller), since I wanted to document the REST based services. I am not able to find an appropriate solution for the same and wanted to device my own solution. I was wondering if there is a component in Spring that would help me to scan through all the controller and help me to fetch out this information. I would like to have a custom build scanner from scratch. Please point me to the API in Spring that would help me do so. I would like to build a customized documentation tool.

One way to fetch all classes from your package and check through reflection like

SomeController.class.isAnnotationPresent(Controller.class)

and the other good way is already specified by @Ralph

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