For a normal MVC controller which annotation do I want? Both are on the classpath.
org.springframework.stereotype.Controller;
org.springframework.web.servlet.mvc.Controller;
I'm using
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.2</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>6.2.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
org.springframework.stereotype.Controller
is an annotationorg.springframework.web.servlet.mvc.Controller
is an interface.Hence there is no choice to make as there is only 1 annotation for this (not including @RestController
which is a further specialization of the @Controller
for rest based controllers).
PRO-TIP: Ditch the spring-framework-bom
as Spring Boot already manages your Spring version, this setup you now have will complicate upgrading.