maven包冲突及解决思路

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.(AbstractRepositoryConfigurationSourceSupport.java:133)

The following method did not exist:

    org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource.(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.png

找到是mongoDb包的问题。想到是springboot项目,原来以前的spring项目的mongoDB引入包应该改为xxxStarter,遂将pom依赖改为如下引入

  
                org.springframework.boot
                spring-boot-starter-data-mongodb
                2.3.2.RELEASE
                
                    
                        spring-data-mongodb
                        org.springframework.data
                    
                
            
            
                org.springframework.data
                spring-data-mongodb
                3.0.3.RELEASE
            -

问题解决。

乍一看不知道怎么解决,如果百度无法给你答案,先猜,然后根据关键字搜索。解决问题后记录。

你可能感兴趣的:(maven包冲突及解决思路)