maven包沖突
前情提要:原項(xiàng)目為spring項(xiàng)目,現(xiàn)需要改為Springboot項(xiàng)目。將pom依賴copy過來后報(bào)錯(cuò)如下:
***************************
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
看異常是包有問題,發(fā)現(xiàn)spring-data-commons/1.13.4.RELEASE出現(xiàn)了多次,那么復(fù)制spring-data-commons到pom文件夾里面去找。

MongoDB.png
找到是mongoDb包的問題。想到是springboot項(xiàng)目,原來以前的spring項(xiàng)目的mongoDB引入包應(yīng)該改為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>-
問題解決。
乍一看不知道怎么解決,如果百度無(wú)法給你答案,先猜,然后根據(jù)關(guān)鍵字搜索。解決問題后記錄。