Reputation: 1742
In Spring DI I love to use @Bean with factory method in @Configuration class instead of using @Component annotation explicitly. Is there a way to do the same with @Controller annotation for Spring Web? In another words, could I declare controller via factory method in some @Configuration class instead of explicit annotation?
Upvotes: 6
Views: 770
Reputation: 5503
Thats not possible since @Controller can only be placed on types. But more important are the methods. I assume you have multiple methods with @RequestMethod annotations. You can place as much methods as you like in this controller with differnet paths. Which should end up in around the same thing as you want?
Upvotes: 1