maven冲突问题解决
在编写maven当中的依赖时,有时候会出现一些问题,这种问题为Maven的当中的依赖。
在导入依赖的时候:出现了两种依赖发生了版本冲突的问题?
<?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冲突 内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Python Pygame实战之实现经营类游戏梦想小镇代码版
作为一名模拟经营类游戏的发烧友,各种农场类、医院类、铁路类的游戏玩儿了很多年。今天用代码给大家打造一款梦想小镇游戏,希望大家喜欢啦2022-12-12
最新评论