When a project is set up to support it, Spring is able to automatically discover new controllers (and other components) by looking for the proper annotation. This makes configuration much simpler, and makes it easier to, for example, add new controllers.
Spring is also able to automatically determine a component's dependencies if they are declared as constructor arguments. In addition to simplifying configuration, this allows us to reduce Java boilerplate code by removing getters and setters.
The report controllers all are already annotated with @Controller. They are also all in a single, small package, and there are no packages below that package. These two factors make the report controllers the ideal first step in moving towards a more modern Spring configuration.
Update the report controllers to use constructor-argument dependency injection, and then tell Spring to look for the annotation rather than explicitly configure each controller in XML.
I tested this by building and deploying, and then logging in as an admin and viewing each of the reports to confirm that they continue to work.
When a project is set up to support it, Spring is able to automatically discover new controllers (and other components) by looking for the proper annotation. This makes configuration much simpler, and makes it easier to, for example, add new controllers.
Spring is also able to automatically determine a component's dependencies if they are declared as constructor arguments. In addition to simplifying configuration, this allows us to reduce Java boilerplate code by removing getters and setters.
The report controllers all are already annotated with
@Controller
. They are also all in a single, small package, and there are no packages below that package. These two factors make the report controllers the ideal first step in moving towards a more modern Spring configuration.Update the report controllers to use constructor-argument dependency injection, and then tell Spring to look for the annotation rather than explicitly configure each controller in XML.
I tested this by building and deploying, and then logging in as an admin and viewing each of the reports to confirm that they continue to work.