有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Maven依赖项排除未按预期工作

我在dependecymanagement下的父pom中添加了依赖项

ParentPom

<dependecyManagement>
<dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>some version</version>
                <exclusions>
                    <exclusion>
                        <groupId>commons-logging</groupId>
                        <artifactId>commons-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
</dependencyManagement>

在我的孩子pom中,我只是在没有版本的依赖中

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </dependency>

当我在我的子pom上做依赖树时,它仍然在树中显示commons日志,这在父pom中被排除

 mvn dependency:tree -Dverbose -Dincludes=commons-logging:commons-logging

这是来自child的dependecy树

[INFO] \- org.springframework:spring-core:jar:parent version .RELEASE:compile
[INFO]    \- commons-logging:commons-logging:jar:some version:compile 

虽然版本号被继承,但为什么不排除依赖项从父pom继承是我要寻找的

Am I assuming anything wrong? or is that how maven behaves?

有效的解决办法将不胜感激

短暂性脑缺血发作


共 (0) 个答案