You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created a simple project with one controller and instead of putting @RestController annotation on the controller class, I am creating it as a bean in the configuration class.
It works in Spring Boot 2.7.10 (and older ones), but after migration to spring boot 3 (I checked it on 3.0.0 and 3.0.5 versions) I am getting 404.
If I remove the bean from the configuration class and add @RestController annotation to controller class, everything works fine, but I would like to have the possibility to e.g. disable the controller from the configuration class level as I used to have.
The difference you're seeing between Spring Boot 2.7 and 3.0 is due to a change in Spring Framework. In Spring Framework 5, a @RequestMapping annotation was enough for Spring to consider the bean as a controller. With Spring Framework 6, a @Controller or @RestController annotation is required to consider the bean as a controller. See spring-projects/spring-framework#22154 (comment) for the details.
I created a simple project with one controller and instead of putting
@RestController
annotation on the controller class, I am creating it as a bean in the configuration class.It works in Spring Boot 2.7.10 (and older ones), but after migration to spring boot 3 (I checked it on 3.0.0 and 3.0.5 versions) I am getting 404.
If I remove the bean from the configuration class and add
@RestController
annotation to controller class, everything works fine, but I would like to have the possibility to e.g. disable the controller from the configuration class level as I used to have.Link to exemplary project:
https://github.com/tomasz0801/spring-playground
It contains one failing test, but if I switch Spring Boot version to 2.7.10 it passes.
The text was updated successfully, but these errors were encountered: