【发布时间】:2019-02-14 06:12:57
【问题描述】:
我正在尝试将我们现有的 Maven 项目之一转换为 Spring Boot。我的项目中没有任何编译错误,但是当我尝试运行它时,出现以下错误:
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.util.MultiValueMap.addAll(Ljava/lang/Object;Ljava/util/List;)V
at org.springframework.core.io.support.SpringFactoriesLoader.loadSpringFactories(SpringFactoriesLoader.java:140)
at org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(SpringFactoriesLoader.java:119)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:426)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:266)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:247)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
at com.myorg.MyMainClass ...
我的 POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>couple of our other internal projects</groupId>
**One of these projects is using spring-context and spring-orm** dependencies.
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
由于我自己项目中的 spring 依赖项是在其他项目之前声明的,所以我认为它会覆盖任何这些传递依赖项。
我已经为此浪费了一整天。有人可以帮忙吗?
【问题讨论】:
-
发布你的 Spring boot 应用的主类。
-
请发布
mvn dependency:tree的输出 -
试着把你的代码和更多的堆栈来帮助我们期待这个问题
标签: java maven spring-boot dependency-management