Analogue of spring @Controller annotation in Java configuration

In Spring DI, I like to use @ Bean with the factory method in the @Configuration class instead of explicitly using the @Component annotation. Is there a way to do the same with @Controller annotation for Spring Web? In other words, can I declare the controller via the factory method in some @Configuration class instead of explicit annotation?

+4
source share
1 answer

This is not possible since @Controller can only be placed in types. But more important are the methods. I assume that you have several methods with @RequestMethod annotations. You can place as many methods as you want on this controller using differnet paths. Which should be around what you need?

+1
source

All Articles