从 Maven pom 中排除传递依赖

Sai*_*pta 1 dependency-management maven transitive-dependency

我在 typetest-jar和 scope 的位置添加了一个 Maven 依赖项test。我想从中删除传递依赖项(因为在 Nexus prod 存储库中缺少此依赖项,这会导致 Jenkins 构建失败)。我添加了一个排除标签,但仍然没有删除依赖项,即 Jenkins 构建仍然失败并抱怨这个依赖项。任何线索为什么?

    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>xxx</artifactId>
        <type>test-jar</type>
        <version>${xxx.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>jamon</artifactId>
                <groupId>com.jamonapi</groupId>
                <!-- <scope>compile</scope> -->
            </exclusion>
        </exclusions>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

Sai*_*pta 6

您可以使用以下命令查找传递依赖项的详细信息,然后您可以排除依赖项:

mvn dependency:tree -Dverbose -Dincludes=<artifact_name>
Run Code Online (Sandbox Code Playgroud)