首页 > 解决方案 > Spring Boot 应用程序中不匹配的托管依赖项导致类路径版本问题

问题描述

我有一个 Spring Boot 应用程序,版本 2.1.7,它引入了 spring-boot-webmvc-5.1.9.RELEASE。maven构建一切都很好。但是,当我尝试启动 spring boot 应用程序时,它会抱怨说:

Correct the classpath of your application so that it contains a single, compatible version of 
org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration

我的依赖树如下所示:

[INFO] +- org.springframework.boot:spring-boot:jar:2.1.7.RELEASE:compile
[INFO] |  \- org.springframework:spring-context:jar:5.1.9.RELEASE:compile
[INFO] |     +- org.springframework:spring-aop:jar:5.1.9.RELEASE:compile
[INFO] |     +- org.springframework:spring-beans:jar:5.1.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:5.1.9.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.1.7.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.1.7.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.1.7.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.1.7.RELEASE:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.11.2:compile
[INFO] |  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.11.2:compile
[INFO] |  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.26:compile
[INFO] |  |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.1.7.RELEASE:test

标签: spring-bootmavendependency-management

解决方案


推荐阅读