如何处理 Maven 缺少工件错误?
我最近刚刚开始进行 Java 开发,并选择了 Maven2 来进行依赖管理和项目任务自动化。
我偶然发现的一个我无法完全理解的特殊问题是,对于某些工件,您需要为其依赖项配置排除项,否则您会得到 Maven Missing artifact groupId:artifactId:version:生命周期错误。我尝试从提供的 STS Spring 项目模板创建 Spring MVC 项目,并且 Maven POM 包含 log4j 的排除项,删除后会产生错误。
那么,当我手动添加依赖项并获得某些依赖项缺少工件错误时,我该怎么办?我是否应该直接将它们添加到排除列表中,还是应该更加小心?
为什么会发生这种情况?我假设一个工件可能具有特定版本的依赖性,而另一个工件具有不同版本的相同依赖性,其中两者不能存在于 classpath
上,或者是其他东西不然我失踪了?
I've just recently started doing Java development and I picked up Maven2 for dependency management and project task automation.
One peculiar issue I've stumbled upon, that I haven't been able to fully understand, is that for certain artifacts you need to configure exclusions for their dependencies, otherwise you get a Maven Missing artifact groupId:artifactId:version:lifecycle
error. I've tried creating a Spring MVC project from the supplied STS Spring project templates and the Maven POM contained exclusions for log4j, which, when removed, would produce an error.
So what do I do when I manually add a dependency and get the missing artifact error for some of it's dependencies. Do I just jump and add them to the list of exclusions or should I be more careful about it?
And why does this happen? I'm assuming it may be perhaps that an artifact has a dependency of a certain version and another artifact has the same dependency of a different version, where both can't exist on the classpath
or is it something else I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果该特定依赖项是在其他地方提供的(无论是在 POM 中明确提供,还是通过其他依赖项提供),您可以配置排除。
如果我收到“未找到工件”消息,我的第一个想法不会是排除它,而是找出需要它的位置,然后将其添加到我的 POM 的相关范围中。
You would configure exclusions if that particular dependency is being supplied elsewhere, either explicitly in your POM, or by another dependency.
If I got an "artifact not found" message my first thought would not be to exclude it, but to find out where it's required, then add it in the relevant scope to my POM.