欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

maven沖突問題解決

 更新時間:2024年04月30日 09:44:53   作者:perfecto1  
這篇文章主要介紹了maven沖突問題解決,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在編寫maven當(dāng)中的依賴時,有時候會出現(xiàn)一些問題,這種問題為Maven的當(dāng)中的依賴。

在導(dǎo)入依賴的時候:出現(xiàn)了兩種依賴發(fā)生了版本沖突的問題?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>spring-mvc</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>6.0.7</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>6.0.4</version>
        </dependency>
    </dependencies>

</project>

首先我是無法知道這個問題出現(xiàn)在哪里的。

可以通過打印maven的版本信息樹來檢查相應(yīng)的依賴

mvn dependency : tree!

直接輸出全部的依賴及其相應(yīng)的版本信息(以樹的形式)

[INFO] -----------------------< org.example:spring-mvc >-----------------------
[INFO] Building spring-mvc 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ spring-mvc ---
[INFO] org.example:spring-mvc:war:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-webmvc:jar:6.0.7:compile
[INFO] |  +- org.springframework:spring-beans:jar:6.0.7:compile
[INFO] |  +- org.springframework:spring-context:jar:6.0.7:compile
[INFO] |  +- org.springframework:spring-core:jar:6.0.7:compile
[INFO] |  |  \- org.springframework:spring-jcl:jar:6.0.7:compile
[INFO] |  +- org.springframework:spring-expression:jar:6.0.7:compile
[INFO] |  \- org.springframework:spring-web:jar:6.0.7:compile
[INFO] |     \- io.micrometer:micrometer-observation:jar:1.10.4:compile
[INFO] |        \- io.micrometer:micrometer-commons:jar:1.10.4:compile
[INFO] \- org.springframework:spring-aop:jar:6.0.4:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.034 s
[INFO] Finished at: 2024-04-29T10:43:24+08:00
[INFO] ------------------------------------------------------------------------

看到具體的編譯情況:那個出現(xiàn)兩個版本的依賴:

org.springframework:spring-aop:jar

最終選擇的是6.0.4:compile版本,也就是說后面編寫dependency,第一種情況就沒有加入進(jìn)去來編譯。

通過展示直接顯示沖突的(omitted for conflict with …)

在這里插入圖片描述

還可以直接使用一種更加簡單的方式來查看沖突:直接使用插件來進(jìn)行查看。

在這里插入圖片描述

? 得到的相應(yīng)查看結(jié)果:

在這里插入圖片描述

為了解決這種沖突的出現(xiàn):可以使用將引起沖突的依賴直接進(jìn)行刪除掉!

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>6.0.7</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

沖突就得到了相應(yīng)的解決!

在這里插入圖片描述

可以使用這種方式來解決沖突的出現(xiàn)!

到此這篇關(guān)于maven沖突問題解決的文章就介紹到這了,更多相關(guān)maven沖突 內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論