简体   繁体   English

Maven 依赖关系显示在依赖关系树中,但没有导入 jar

[英]Maven dependency shows in dependency tree but no jar is imported

The project I am working at has many levels and a parent pom, so, hard to assess the ultimate result of dependencies imported.我正在从事的项目有很多级别和一个父 pom,因此很难评估导入的依赖项的最终结果。

However, looking into the dependency:tree and the effective pom, I can see i am correctly importing JUnit-jupiter 5.5.2, but i cannot see the jar on the list of maven dependencies on my project, I actually see JUnit-jupiter 5.2.0.但是,查看依赖项:树和有效的 pom,我可以看到我正确导入了 JUnit-jupiter 5.5.2,但我在我的项目的 maven 依赖项列表中看不到 jar,我实际上看到了 JUnit-jupiter 5.2 .0.

Already tried mvc clean install -U已经尝试过 mvc clean install -U

Any ideas?有任何想法吗?

jars and dependecy:tree jars 和依赖:树罐子和依赖:树

effective-pom有效的 pom 有效的 pom

The reason for JUnit-jupiter 5.2.0 is still in your project could be due to, it comes as a transitive dependency of some other dependency. JUnit-jupiter 5.2.0 仍在您的项目中的原因可能是因为它是其他一些依赖项的传递依赖项。 What you can do is look for parent dependency of JUnit-jupiter 5.2.0 and exclude transitive dependencies from it.您可以做的是查找 JUnit-jupiter 5.2.0 的父依赖项并从中排除传递依赖项。

使用项目的图形依赖树并展开所有传递依赖并搜索 jupiter lib

Use graphical dependency tree of your project and expand all transitive dependencies and search jupiter library.使用项目的图形依赖树并扩展所有传递依赖并搜索 jupiter 库。 If there is JUnit-jupiter 5.2.0 as a transitive dependency you can exclude it as below.如果有 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>

Managed to import the correct jar by excluding the transitive dependency in dependency management in pom:通过排除 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM