maven沖突問題解決
在編寫maven當中的依賴時,有時候會出現一些問題,這種問題為Maven的當中的依賴。
在導入依賴的時候:出現了兩種依賴發(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>
首先我是無法知道這個問題出現在哪里的。
可以通過打印maven的版本信息樹來檢查相應的依賴
mvn dependency : tree!
直接輸出全部的依賴及其相應的版本信息(以樹的形式)
[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] ------------------------------------------------------------------------
看到具體的編譯情況:那個出現兩個版本的依賴:
org.springframework:spring-aop:jar
最終選擇的是6.0.4:compile版本,也就是說后面編寫dependency,第一種情況就沒有加入進去來編譯。
通過展示直接顯示沖突的(omitted for conflict with …)

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

? 得到的相應查看結果:

為了解決這種沖突的出現:可以使用將引起沖突的依賴直接進行刪除掉!
<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>
沖突就得到了相應的解決!

可以使用這種方式來解決沖突的出現!
到此這篇關于maven沖突問題解決的文章就介紹到這了,更多相關maven沖突 內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
pyspark.sql.DataFrame與pandas.DataFrame之間的相互轉換實例
今天小編就為大家分享一篇pyspark.sql.DataFrame與pandas.DataFrame之間的相互轉換實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08
python創(chuàng)建學生成績管理系統(tǒng)
這篇文章主要為大家詳細介紹了python創(chuàng)建學生成績管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-11-11
簡單談談Python中的元祖(Tuple)和字典(Dict)
這篇文章主要介紹了關于Python中元祖(Tuple)和字典(Dict)的相關資料,文中通過示例代碼介紹的非常詳細,相信對大家具有一定的參考價值,需要的朋友們下面來一起看看吧。2017-04-04

