Vojtěch Vojtěch - 1 year ago 117
Java Question

Getting all annotated controllers with @Controller

Is there a way to get a list of all Controllers, which were annotated with

? I would like to use them like:

public void addAll(List<Controller> controllers) throws Exception {
for (Controller controller : controllers) {


Answer Source


If you have annotated them with controller ... :

private ListableBeanFactory listableBeanFactory;


Map<String, Object> controllers;
controllers = listableBeanFactory.getBeansWithAnnotation(Controller.class);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download