我的 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>
但我仍然遇到同样的错误。
编辑2
我可以用这个让它工作
<properties>
<analyze.dependency.skip>true</analyze.dependency.skip>
</properties>
但是,是否可以仅跳过我的依赖项。
最佳答案
您的父 pom 包含以下插件
org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-dep-mgt
这会检查依赖项的一致性(您可以通过下载父 pom 来查找)。
再次声明插件并设置<skip>
至true
以避免此检查。
或者:如果您的父 pom 定义了一个可以设置为跳过执行的属性,请将此属性设置为 false。
关于java - 取消子项目中父项目的 Maven 排除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46108926/