maven包冲突
前情提要:原项目为spring
项目,现需要改为Springboot
项目。将pom依赖copy过来后报错如下:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport$AutoConfiguredAnnotationRepositoryConfigurationSource.<init>(AbstractRepositoryConfigurationSourceSupport.java:133)
The following method did not exist:
org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.<init>(Lorg/springframework/core/type/AnnotationMetadata;Ljava/lang/Class;Lorg/springframework/core/io/ResourceLoader;Lorg/springframework/core/env/Environment;Lorg/springframework/beans/factory/support/BeanDefinitionRegistry;Lorg/springframework/beans/factory/support/BeanNameGenerator;)V
The method's class, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource, is available from the following locations:
jar:file:/D:/DevelopSoftWare/maven_rely_jar/org/springframework/data/spring-data-commons/1.13.4.RELEASE/spring-data-commons-1.13.4.RELEASE.jar!/org/springframework/data/repository/config/AnnotationRepositoryConfigurationSource.class
The class hierarchy was loaded from the following locations:
org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource: file:/D:/DevelopSoftWare/maven_rely_jar/org/springframework/data/spring-data-commons/1.13.4.RELEASE/spring-data-commons-1.13.4.RELEASE.jar
org.springframework.data.repository.config.RepositoryConfigurationSourceSupport: file:/D:/DevelopSoftWare/maven_rely_jar/org/springframework/data/spring-data-commons/1.13.4.RELEASE/spring-data-commons-1.13.4.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource
Disconnected from the target VM, address: '127.0.0.1:58560', transport: 'socket'
Process finished with exit code 1
看异常是包有问题,发现spring-data-commons/1.13.4.RELEASE
出现了多次,那么复制spring-data-commons
到pom文件夹里面去找。
找到是mongoDb
包的问题。想到是springboot
项目,原来以前的spring
项目的mongoDB
引入包应该改为xxxStarter
,遂将pom
依赖改为如下引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>2.3.2.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>spring-data-mongodb</artifactId>
<groupId>org.springframework.data</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>-
问题解决。
乍一看不知道怎么解决,如果百度无法给你答案,先猜,然后根据关键字搜索。解决问题后记录。