我是 Maven 新手,正在努力添加依赖项.我正在尝试将现有项目转换为 Maven,在为我引用的库中的所有 jar 添加依赖项后,我收到一条关于缺少工件的错误消息:
I'm new to Maven, and struggling with adding dependencies. I'm trying to convert an existing project to Maven, and after adding the dependencies for all the jars in my referenced libraries, I'm receiving an error message about missing artifacts:
Missing artifact stax:stax:jar:1.0
Missing artifact clover:clover:jar:1.3-rc4
Missing artifact log4j:log4j:bundle:1.2.16
Missing artifact stax:stax-ri:jar:1.0
通过阅读这篇文章:如何处理 Maven 缺少工件错误?,听起来我需要手动下载这些jar并将它们添加到我的本地maven存储库中.我的问题是如何找到这些罐子?我试着用谷歌搜索它们,我可以找到名称相似的罐子,但不完全像这些,所以我不确定它们是否是正确的罐子.
From reading this post: How to handle Maven missing artifact errors?, it sounds like I need to manually download these jars and add them to my local maven repository. My question is how do I find these jars? I tried googling them, and I can find jars that have similar names, but not exactly like these, so I'm not sure if they're the right jars.
有什么技巧可以解决这个问题吗?log4j jar 是我原始项目的引用库中唯一明确列出的,所以我猜其他的是我拥有的其他 jar 所需要的,我不知道在哪里可以找到它们或它们的确切名称应该是.
Any tips for dealing with this problem? The log4j jar is the only one explicitly listed in the referenced libraries of my original project, so I'm guessing the other ones are required by other jars that I have, and I don't know where to find them or what their exact names should be.
谢谢!
感谢大家的回复.问题的实际原因是,对于这 3 个缺失的工件中的每一个,由于某种原因,当 Maven 将它们下载到我的本地存储库中时,.lastUpdated 被附加到 jar 的末尾.例如,stax-1.0.jar.lastUpdated.这就是 Maven 找不到 stax-1.0.jar 的原因.
Thanks to everyone for responding. The actual cause of the problem is that for each of those 3 missing artifacts, for some reason, when Maven downloaded them into my local repository, .lastUpdated was appended to the end of the jar. For example, stax-1.0.jar.lastUpdated. This is the reason Maven could not find stax-1.0.jar.
所以,为了解决这个问题,我必须手动下载 stax-1.0.jar,然后将其安装到本地 maven 存储库中与混乱文件完全相同的位置,以便 Maven 可以找到它.(例如,使用命令:
So, to fix this problem, I had to manually download stax-1.0.jar, then install it into the local maven repository in the exact same place as the messed up file, so that Maven could find it. (For example, using the command:
mvn install:install-file -Dfile=<path-to-file>/stax-1.0.jar
-DgroupId=stax -DartifactId=stax -Dversion=1.0 -Dpackaging=jar
使用与现有的不正确文件完全相同的 groupId 和 artifactId 对于 maven 找到它至关重要.
Using the same exact groupId and artifactId as the existing, incorrect file was crucial in order for maven to find it.
这篇关于查找丢失的 Maven 工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!