In my Application, I wanted to list down all of my controllers and request method. Can anybody tell how can I detect the controller annotation in the application?
You could get a starting point by:
1) Injecting
@Autowired
private ApplicationContext applicationContext;
2) Using
String[] getBeanNamesForType(@Nullable
Class<?> type)
If your controllers all extend a common base.
3) Use the
String[] getBeanDefinitionNames()
And then filter the ones ending in Controller.. if that is your common suffix for these.
For the methods themselves, you would most likely need to use reflection once you have the qualified controller class names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With