如何处理Maven缺少工件错误? [英] How to handle Maven missing artifact errors?

查看:82
本文介绍了如何处理Maven缺少工件错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近才开始进行Java开发,我选择了Maven2进行依赖项管理和项目任务自动化.

I've just recently started doing Java development and I picked up Maven2 for dependency management and project task automation.

我偶然发现的一个我尚未完全理解的特殊问题是,对于某些工件,您需要为其依赖项配置排除项,否则会出现Maven Missing artifact groupId:artifactId:version:lifecycle错误.我尝试从提供的STS Spring项目模板创建Spring MVC项目,并且Maven POM包含 log4j 的排除项,将其删除后会产生错误.

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?

为什么会这样?我假设某个工件可能具有某个版本的依赖性,而另一个工件具有另一个版本的相同依赖性,这两个工件在classpath上可能都不存在,或者是我遗漏了其他某些东西?

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?

推荐答案

如果该特定依赖项是在其他位置提供的,则可以配置排除项,无论是在POM中显式提供还是由其他依赖项提供.

You would configure exclusions if that particular dependency is being supplied elsewhere, either explicitly in your POM, or by another dependency.

如果收到找不到工件"消息,我首先想到的不是排除它,而是要找出它的需要,然后将其添加到我的POM的相关范围内.

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.

这篇关于如何处理Maven缺少工件错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆