Java Maven:无法读取工件描述符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6642146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven: Failed to read artifact descriptor
提问by Morrislgn
I am hoping someone can help me with a problem I am struggling with.
我希望有人可以帮助我解决我正在努力解决的问题。
When I try to build my project from the terminal I get this error:
当我尝试从终端构建我的项目时,出现此错误:
Failed to read artifact descriptor for com.morrislgn.merchandising.common:test-data-utils:jar:0.3b-SNAPSHOT: Could not find artifact com.morrislgn.merchandising:merchandising:pom:0.3b-SNAPSHOT
The common.test-data-utils
jar is created by a separate project and shared between this and another project (the other project doesn't build either, but that is down to another problem).
该common.test-data-utils
JAR是由一个单独的项目创建,这和其他项目之间共享(其他项目不建或者,但那是下来的问题)。
I am able to build com.morrislgn.merchandising.common:test-data-utils
without issue, I can see the entry it makes in the .m2
local repository on my machine. I have reindexed my repository in Eclipse also.
我可以com.morrislgn.merchandising.common:test-data-utils
毫无问题地构建,我可以看到它.m2
在我机器上的本地存储库中创建的条目。我也在 Eclipse 中重新索引了我的存储库。
The POM for my project has this entry:
我的项目的 POM 有这个条目:
<dependency>
<groupId>com.morrislgn.merchandising.common</groupId>
<artifactId>test-data-utils</artifactId>
<version>0.3b-SNAPSHOT</version>
</dependency>
Which appears to be correct to me - the POM doesn't report any errors either when it is viewed in Eclipse.
这对我来说似乎是正确的 - 在 Eclipse 中查看 POM 时,它也不会报告任何错误。
Can some one tell me what I am missing here or doing wrong?
有人可以告诉我我在这里缺少什么或做错了什么吗?
回答by phlogratos
You mention two different groupIds, com.morrislgn.merchandising.common
and com.johnlewis.jec.webpim.common
. Maybe this is the problem.
您提到了两个不同的 groupIdcom.morrislgn.merchandising.common
和com.johnlewis.jec.webpim.common
. 也许这就是问题所在。
回答by Dean Hiller
I had the same issue with eclipse where the maven build command line worked just fine BUT try this
我在 eclipse 中遇到了同样的问题,其中 Maven 构建命令行工作得很好但是试试这个
- go into .m2/repository and wipe the directory associated
- run update maven dependencies in eclipse
- 进入 .m2/repository 并擦除关联的目录
- 在 Eclipse 中运行更新 Maven 依赖项
The error goes away....why my mvn command line worked with those directories and eclipse .m2eclipse could not, I have no idea and it kinda sucks. My project is now working in eclipse again.
错误消失了....为什么我的 mvn 命令行与这些目录一起工作而 eclipse .m2eclipse 不能,我不知道,它有点糟糕。我的项目现在再次在 eclipse 中工作。
回答by 17sprints
I solved this issue by deleting in the repository folders where this error was shown everything except the .jar and .pom files.
我通过在存储库文件夹中删除了这个错误来解决这个问题,除了 .jar 和 .pom 文件之外的所有内容。
回答by eaykin
"Failed to read artifact descriptor" problems generally indicate a problem with the dependency's pom file in the maven repository. I would suggest you to double check if the pom file's name is the same with the name maven expects, and also to check if the pom file contents are valid.
“无法读取工件描述符”问题通常表示 maven 存储库中依赖项的 pom 文件存在问题。我建议您仔细检查 pom 文件的名称是否与 maven 期望的名称相同,并检查 pom 文件内容是否有效。
回答by Gal Bracha
You can always try mvn -U clean install
你可以随时尝试 mvn -U clean install
-U
forces a check for updated releases and snapshots on remote repositories.
-U
强制检查远程存储库上的更新版本和快照。
回答by rrs
I know I'm pretty late to the conversation, but I had this problem too. I think the issue was my company's firewall. My solution was to unplug from the network, connect to our open wireless and then force an update via Eclipse. This resolved everything.
我知道我的谈话已经很晚了,但我也遇到了这个问题。我认为问题出在我公司的防火墙上。我的解决方案是拔掉网络,连接到我们的开放无线网络,然后通过 Eclipse 强制更新。这解决了一切。
回答by Toothless Seer
Did not have any luck updating via eclipse. Had to use mvn clean install -U (which resolved everything).
通过日食更新没有任何运气。不得不使用 mvn clean install -U (它解决了所有问题)。
回答by Roshan Khandelwal
For me , it was related to setting the "User Setting.xml" inside
对我来说,这与在里面设置“User Setting.xml”有关
Window > preferences > Maven > User Settings > and then browsing to the user Settings inside the { maven unarchived directory / }/apache-maven-2.2.1/conf/settings.xml .
回答by bzuillsmith
This problem can occur if you have some child projects that refer to a parent pom and you have not installed from the parent pom directory (run mvn install
from the parent directory). One of the child projects may depend on a sibling project and when it goes to read the pom of the sibling, it will fail with the error mentioned in the question unless you have installed from the parent pom directory at least once.
如果您有一些引用父 pom 的子项目并且您没有从父 pom 目录安装(mvn install
从父目录运行),则会出现此问题。子项目之一可能依赖于同级项目,当它读取同级项目的 pom 时,它将失败并出现问题中提到的错误,除非您至少从父 pom 目录安装了一次。
I just ran into this problem when moving a project to a new computer. I was in the habit of running commands from the child project and didn't run install on the parent.
我在将项目移动到新计算机时遇到了这个问题。我习惯于从子项目运行命令,并没有在父项目上运行安装。
回答by simpleDev
I have a project
我有一个项目
A/
|--a1
|--a2
Now there is another project in our org
现在我们的组织中有另一个项目
B/
|--b1
|--b2
|--b3
(Every module a1, b1 etc. and Parent projects A, B have their own pom.xml as per standard maven rules of parent and child)
(每个模块 a1、b1 等和父项目 A、B 都有自己的 pom.xml,按照父子的标准 maven 规则)
Both projects are checked out on my local eclipse (from SVN). I am actively working on A.
这两个项目都在我的本地日食(来自 SVN)上签出。我正在积极地研究 A。
I came to know that there is a good common functionality (b4) developed in B and I needed to use it.
我开始知道在 B 中有一个很好的通用功能(b4),我需要使用它。
B/
|--b1
|--b2
|--b3
|--b4 (NEW)
Developer of b4 have deployed this b4 module as an artifact in our org's repository. I included the dependancy to my module's POM i.e. a2's pom.xml. Eclipse downloaded the reuqired artifact from repo and I could import the classes in it.
b4 的开发人员已将此 b4 模块部署为我们组织存储库中的工件。我包含了对我模块 POM 的依赖,即 a2 的 pom.xml。Eclipse 从 repo 下载了需要的工件,我可以导入其中的类。
Now issue starts... I needed to check the source code of b4 for some purpose and as I already had B checked out on my local eclipse I updated it from SVN and checked out module b4. I also ran pom.xml of module b4 with targets like clean, package etc. After some time when I finishedd my coding I needed to create a JAR of my module a2. I ran "package" on a2's pom.xml and BAM!! errors n errors for a2 module.. These errors were also not very user friendly. Only thing is there was b4's name for sure in logs.
现在问题开始了……出于某种目的,我需要检查 b4 的源代码,因为我已经在本地 eclipse 上检出了 B,所以我从 SVN 更新了它并检出了模块 b4。我还运行了模块 b4 的 pom.xml,目标是像 clean、package 等。一段时间后,当我完成编码后,我需要创建模块 a2 的 JAR。我在 a2 的 pom.xml 和 BAM 上运行了“包”!!错误 a2 模块的 n 个错误。这些错误对用户也不是很友好。唯一的问题是日志中肯定有 b4 的名字。
Solution: After trying for many solutions for many hours, I ran "mvn -U clean install" from console in my B's project directoty (i.e. in ../codebase/B). As B is the parent, clean install command ran for all modules including b4 and it ran successfully. After this I ran "mvn -U clean install" for my parent project which is A. And this worked! a2 module got compiled, installed, (packaged later) succesfully.
解决方案:在尝试了许多解决方案数小时后,我在 B 的项目目录中(即在 ../codebase/B 中)从控制台运行了“mvn -U clean install”。由于 B 是父级,因此对包括 b4 在内的所有模块运行了全新安装命令,并且运行成功。在此之后,我为我的父项目 A 运行了“mvn -U clean install”。这奏效了!a2 模块已成功编译、安装(稍后打包)。
Here important point was if b4 is in your workspace do not only install b4. You will need to clean-install complete B. I came up to this solution after reading answer from Zuill
这里重要的一点是,如果 b4 在您的工作区中,请不要只安装 b4。您将需要全新安装完整的 B。我在阅读Zuill 的回答后想到了这个解决方案
EDIT: One more thing here to note that if I didn't had B project checked out in Local environment then this issue might not have occurred for me. I tend to think that this happened cause I had B checked out in my local workspace.
编辑:这里还有一件事要注意,如果我没有在本地环境中检出 B 项目,那么这个问题可能不会发生在我身上。我倾向于认为这是因为我在本地工作区检查了 B。