如何找到我的 Junit4 依赖项在 Maven 项目中引入的位置?

问题描述 投票:0回答:1

我已将 Maven 项目从 Junit4 迁移到 Junit5,并删除了这一行:

<junitVersion>4.9</junitVersion>

来自我的 pom.xml 文件。

但不知何故,我仍然可以使用这个

import org.junit.Test;

在我的代码中,我想知道我的哪个库将 Junit4 作为传递依赖项引入。

我使用了

mvn dependency:tree
,这是我所拥有的,但我在任何地方都没有看到Junit4:

[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.7.16:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.7.16:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.7.16:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:4.5.1:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.1:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.9.1:test
[INFO] +- org.springframework:spring-test:jar:5.3.30:compile
[INFO] |  \- org.springframework:spring-core:jar:5.3.30:compile
[INFO] |     \- org.springframework:spring-jcl:jar:5.3.30:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.30:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- org.junit.platform:junit-platform-launcher:jar:1.2.0:compile
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.0.0:compile
[INFO] |  \- org.junit.platform:junit-platform-engine:jar:1.8.2:compile (version managed from 1.2.0)
[INFO] |     +- org.opentest4j:opentest4j:jar:1.2.0:compile
[INFO] |     \- org.junit.platform:junit-platform-commons:jar:1.8.2:compile
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test

任何想法将不胜感激!

java spring-boot maven junit junit5
1个回答
0
投票

将此排除添加到您的

spring-boot-starter-test
中的
pom.xml
依赖项中:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
  <exclusions>
    <exclusion>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </exclusion>
  </exclusions>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.