maven依赖冲突解决_Maven依赖树–解决冲突

本文介绍了如何利用Maven的依赖树命令解决项目中的依赖冲突,通过排除依赖、详细模式查看冲突以及过滤依赖树等方法进行管理。同时,讲解了在Eclipse IDE中查看Maven依赖树的方法。
摘要由CSDN通过智能技术生成

maven依赖冲突解决

Maven Dependency Tree is very helpful in understanding the project dependencies and resolving any conflicts because of different versions of a dependency.

Maven依赖关系树对于理解项目依赖关系和解决由于依赖关系版本不同而引起的任何冲突非常有帮助。

如何获取项目的Maven依赖树 (How to get the Maven Dependency Tree of a Project)

We can run mvn dependency:tree command in the terminal to print the project dependency tree.

我们可以在终端中运行mvn dependency:tree命令以打印项目依赖关系树。

For our example, I will be using the Mockito Tutorial project. You can download the project from the GitHub repository.

对于我们的示例,我将使用Mockito Tutorial项目。 您可以从GitHub存储库下载项目。

We are interested only in the project dependencies. The pom.xml has declared the following project dependencies.

我们仅对项目依赖项感兴趣。 pom.xml声明了以下项目依赖项。

<dependencies>
	<dependency>
		<groupId>org.junit.platform</groupId>
		<artifactId>junit-platform-runner</artifactId>
		<version>1.2.0</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.junit.jupiter</groupId>
		<artifactId>junit-jupiter-engine</artifactId>
		<version>5.2.0</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.mockito</groupId>
		<artifactId>mockito-junit-jupiter</artifactId>
		<version>2.19.0</version>
		<scope>test</scope>
	</dependency>
	<!-- TestNG Dependencies -->
	<dependency>
		<groupId>org.testng</groupId>
		<artifactId>testng</artifactId>
		<version>6.14.3</version>
		<scope>test</scope>
	</dependency>
</dependencies>

Let’s see the output when we run the maven dependency tree command.

让我们看看运行maven依赖树命令时的输出。

$ mvn dependency:tree                                                              
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------------
[INFO] Building Mockito-Examples 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ Mockito-Examples ---
[INFO] com.journaldev.mockito:Mockito-Examples:jar:1.0-SNAPSHOT
[INFO] +- org.junit.platform:junit-platform-runner:jar:1.2.0:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:test
[INFO] |  +- org.junit.platform:junit-platform-launcher:jar:1.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-suite-api:jar:1.2.0:test
[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.2.0:test
[INFO] |  \- junit:junit:jar:4.12:test
[INFO] |     \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.2.0:test
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.2.0:test
[INFO] |  |  \- org.opentest4j:opentest4j:jar:1.1.0:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-api:jar:5.2.0:test
[INFO] +- org.mockito:mockito-junit-jupiter:jar:2.19.0:test
[INFO] |  \- org.mockito:mockito-core:jar:2.19.0:test
[INFO] |     +- net.bytebudd
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值