Maven依赖关系显示在依赖关系树中,但未导入任何jar

时间:2019-10-10 09:02:16

标签: java maven intellij-idea junit5

我正在从事的项目有多个层次和一个父pom,因此,很难评估导入的依赖项的最终结果。

但是,查看dependency:tree和有效的pom,我可以看到我正确地导入了JUnit-jupiter 5.5.2,但是我看不到我项目的maven依赖项列表上的jar,我实际上看到了JUnit -jupiter 5.2.0。

已经尝试过mvc全新安装-U

有什么想法吗?

罐子和dependecy:树 jars and dependecy:tree

有效pom effective-pom

2 个答案:

答案 0 :(得分:2)

JUnit-jupiter 5.2.0仍在您的项目中的原因可能是由于,它是其他一些依赖的传递依赖。您可以做的是查找JUnit-jupiter 5.2.0的父级依赖项,并从中排除传递性依赖项。

Use graphical dependency tree of your project and expand all transitive dependencies and search jupiter lib

使用项目的图形依赖树,展开所有传递依赖关系并搜索jupiter库。 如果将JUnit-jupiter 5.2.0作为传递依赖项,则可以按如下所示排除它。

    <dependency>
        <groupId>it.some.parent</groupId>
        <artifactId>parent-library</artifactId>
        <version>${parent.library.version}</version>
        <scope>provided</scope>
        <exclusions>
            <exclusion>
                <groupId>*</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

答案 1 :(得分:0)

通过在pom的依赖管理中排除传递依赖来管理导入正确的jar:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring-boot.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
            </exclusions>
        </dependency>