从子项目中的父项目中取消maven排除项

时间:2017-09-08 04:56:52

标签: java maven

我的pom

中有以下内容
<dependencyManagement>
    <dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.13</version>
        <!-- <scope>compile</scope>-->
    </dependency>       
    </dependencies>

    </dependencyManagement>

    <dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.13</version>
        <!-- <scope>compile</scope>-->
    </dependency>

基本上,我希望将slf4j-log4j12作为依赖项包含在内。但是,当我mvn clean install时,我收到以下错误:

[INFO] log4j:log4j:jar was excluded in DepMgt, but version 1.2.17 has been found in the dependency tree.
[INFO] org.slf4j:slf4j-log4j12:jar was excluded in DepMgt, but version 1.7.13 has been found in the dependency tree.


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-dep-mgt (analyze-dependency) on project my-project: Found Dependency errors. -> [Help 1]

此库似乎已在父项目中排除。有没有办法取消排除并将其包含在此项目中?

修改

我尝试添加此

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>
                            analyze-dep-mgt
                            </goal>
                        </goals>
                    </execution>
                </executions>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
            </plugin>
        </plugins>
    </build>

但我仍然得到同样的错误。

EDIT2

我可以使用此

使其工作
<properties>
    <analyze.dependency.skip>true</analyze.dependency.skip>
    </properties>

但是,是否可以跳过我的依赖。

1 个答案:

答案 0 :(得分:2)

您的父pom包含以下插件

org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-dep-mgt

这会检查依赖项的一致性(您可以通过下载父pom来查找)。

再次声明插件并将<skip>设置为true以避免此检查。

或者:如果您的父pom定义了一个可以设置为跳过执行的属性,请将此属性设置为false。