[英]How to tell maven-dependency-plugin that the artifact is used in the project?
这是我的多模块项目的结构:
/root
/api dependencies: slf4j
/foo dependencies: slf4j-log4j12, log4j
换句话说,模块api
使用slf4j
进行日志记录。 它不知道日志工具的实现是什么。 模块foo
添加了slf4j-log4j12
和log4j
以实现日志记录。 很简单。
现在我正在运行maven-dependency-plugin:analyze-only
,这就是它对模块foo
所说的:
[WARNING] Unused declared dependencies found:
[WARNING] org.slf4j:slf4j-log4j12:jar:1.6.1:compile
[WARNING] log4j:log4j:jar:1.2.16:compile
这意味着插件不理解foo
确实需要这些依赖项。 我该如何解决这个问题?
如果您将这些依赖项赋予runtime
作用域而不是compile
什么?
如果你已经将它们定义为编译时依赖项,我认为依赖插件会认为它们在编译时需要它们才真正没有。 但是在运行时只需要slf4-log4j和log4j JAR文件。
编辑:您可能需要设置ignoreNonCompile
选项:
http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html
您是否尝试将slf4j-log4j12
和log4j
的范围设置为运行时?
请参阅maven依赖范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.