[英]How to tell maven-dependency-plugin that the artifact is used in the project?
This is a structure of my multi-module project: 这是我的多模块项目的结构:
/root
/api dependencies: slf4j
/foo dependencies: slf4j-log4j12, log4j
In other words, module api
uses slf4j
for logging purposes. 换句话说,模块
api
使用slf4j
进行日志记录。 It doesn't know what the implementation of logging facility will be. 它不知道日志工具的实现是什么。 Module
foo
adds slf4j-log4j12
and log4j
in order to implement the logging. 模块
foo
添加了slf4j-log4j12
和log4j
以实现日志记录。 Pretty simple. 很简单。
Now I'm running maven-dependency-plugin:analyze-only
and this is what it says for module foo
: 现在我正在运行
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
Meaning that the plugin doesn't understand that foo
really needs these dependencies. 这意味着插件不理解
foo
确实需要这些依赖项。 How can I solve the problem? 我该如何解决这个问题?
What happens if you give those dependencies a runtime
scope instead of compile
? 如果您将这些依赖项赋予
runtime
作用域而不是compile
什么?
If you've defined them as compile-time dependencies I think the dependency plugin will think they are needed for the compile when they're really not. 如果你已经将它们定义为编译时依赖项,我认为依赖插件会认为它们在编译时需要它们才真正没有。 But you only need the slf4-log4j and log4j JAR files at runtime.
但是在运行时只需要slf4-log4j和log4j JAR文件。
Edit: You may need to set the ignoreNonCompile
option: 编辑:您可能需要设置
ignoreNonCompile
选项:
http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html
Have you tried setting the scope of slf4j-log4j12
and log4j
to runtime? 您是否尝试将
slf4j-log4j12
和log4j
的范围设置为运行时?
See maven dependency scope 请参阅maven依赖范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.