如何告诉maven-dependency-plugin项目中使用了该工件?
这是我的多模块项目的结构:
/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
确实需要这些依赖项。我该如何解决这个问题?
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. 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. Pretty simple.
Now I'm running maven-dependency-plugin:analyze-only
and this is what it says for module 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. How can I solve the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您为这些依赖项提供运行时范围而不是编译范围,会发生什么情况?
如果您将它们定义为编译时依赖项,我认为依赖项插件会认为编译需要它们,但实际上并非如此。但运行时您只需要 slf4-log4j 和 log4j JAR 文件。
编辑:您可能需要设置
ignoreNonCompile
选项:http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html
What happens if you give those dependencies a
runtime
scope instead ofcompile
?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.
Edit: You may need to set the
ignoreNonCompile
option:http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html
您是否尝试过将
slf4j-log4j12
和log4j
的范围设置为运行时?请参阅 maven 依赖范围
Have you tried setting the scope of
slf4j-log4j12
andlog4j
to runtime?See maven dependency scope