我有一个 Maven 项目,它有
spring-boot-starter-parent
版本 2.7.10
作为父级,spring-boot-starter-web
作为依赖项。
我升级了
spring-boot-starter-web
使用<version>3.0.5</version>
.
但是在 mvn dependency:tree 中,我仍然得到
spring-webmvc
旧版本,即 5.3.20.
当我尝试打开
spring-boot-starter-web
的 pom 时,它清楚地显示了编译依赖性:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.7</version>
<scope>compile</scope>
</dependency>
谁能帮我理解为什么升级
spring-boot-starter-web
版本没有升级spring-webmvc版本?我已明确添加以暂时解决此问题:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.7</version>
<scope>compile</scope>
</dependency>
但是我不确定这样的层级依赖升级是不是正确的方式
注意:我的最终目标是将 spring-webmvc 从 5.3.20 升级到 6.0.7
你应该只在父 pom 中管理版本。 尝试将 spring-boot-starter-parent 升级到 3.0.5 并让 spring-boot-starter-web 的版本隐式(删除版本标签)。 如果你想要更精确的依赖管理并且不让你父母的版本泄漏,请使用 dependencyManagement 标签