maven包沖突及解決思路

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)鍵字搜索。解決問題后記錄。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容