Java <name> 的 POM 无效,传递依赖(如果有)将不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23581194/
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
The POM for <name> is invalid, transitive dependencies (if any) will not be available
提问by AreusAstarte
This question is outdated and no longer relevant. I have since moved to Gradle for my project build and can no longer verify that answers do or do not work.
这个问题已经过时,不再相关。从那以后,我已经转移到 Gradle 进行我的项目构建,并且无法再验证答案是否有效。
I've run into a few issues with Maven. Let me first describe my project setup:
我遇到了 Maven 的一些问题。让我先描述一下我的项目设置:
Framework
| -- Apache Commons Math 3.0
| -- Bouncy Castle 1.5
| -- etc.. (lots more)
|________
| Client
| | -- GUI libraries
| | -- etc.
|
|________
Server
| -- Server Libraries
| -- etc.
So essentially I have a framework that contains most dependancies and then two projects, "Server" and "Client" that contain their own BUT also the framework as a dependancy (being a module of Framework.). I installed the Framework project into my local repository and both my projects can see the Framework-Native code (aka my own logic). HOWEVER they don't seem to be able to use any of the dependancies of the Framework Project. When trying to build either of the "child"-projects I get this:
所以基本上我有一个包含大多数依赖项的框架,然后是两个项目,“服务器”和“客户端”,它们包含自己的但也包含框架作为依赖项(作为框架的一个模块。)。我将 Framework 项目安装到我的本地存储库中,我的两个项目都可以看到 Framework-Native 代码(也就是我自己的逻辑)。然而,他们似乎无法使用框架项目的任何依赖项。当尝试构建任何一个“子”项目时,我得到了这个:
Invalid POM for de.r2soft.empires.framework:Framework:jar:Alpha-1.2,
transitive dependencies (if any) will not be available,
enable debug logging for more details
I've tried to find the reason behind this (or better yet a solution) but haven't found anything that fixed my issues. Hope someone here can help. My maven version seems to be 3.2.1 (that's what -version tells me anyways)
我试图找到这背后的原因(或者更好的解决方案),但没有找到任何解决我问题的方法。希望这里有人可以提供帮助。我的 maven 版本似乎是 3.2.1(这就是 -version 告诉我的)
Here are my framework-pom.xml and the client-pom.xml on pastebin:
这是我在 pastebin 上的 framework-pom.xml 和 client-pom.xml:
Framework: http://pastebin.com/cceZECaT
框架:http: //pastebin.com/cceZECaT
Client: http://pastebin.com/1Cuxve5F
客户端:http: //pastebin.com/1Cuxve5F
Help is appreciated.
帮助表示赞赏。
回答by tmarwen
The the Frameworkartifact available in your local repository before running an install
on the clientproject because there is no coupling between the two projects (the clientartifact is not a module
of your Frameworkproject).
在客户端项目上运行之前,本地存储库中可用的Framework工件,因为两个项目之间没有耦合(客户端工件不是您的Framework项目的一个)。install
module
So to solve the issue you should run mvn install
on your Frameworkproject so the packaged jar is copied to your local repository. Then it is up to maven to discover and find it when you run some maven phase on the clientproject.
因此,要解决该问题,您应该mvn install
在Framework项目上运行,以便将打包的 jar 复制到您的本地存储库。然后,当您在客户端项目上运行某个 Maven 阶段时,由 Maven 来发现并找到它。
To have your artifacts shared among your organization you should deploy your artifacts (upload) to a nexus hosting mirror.
要在您的组织中共享您的工件,您应该将您的工件(上传)部署到 nexus 托管镜像。
回答by Olivier D
I have the same kind of issue and I may have the answer.
I have a top level project MyProject
and Module1
and Module2
.
Module2
depends on Module1
and the entry is listed as a (default) dependency.
MyProject
我有同样的问题,我可能有答案。我有一个顶级项目MyProject
和Module1
和Module2
。
Module2
取决于Module1
并且该条目被列为(默认)依赖项。我的项目
<modules>
Module1
Module2
</modules>
mvn dependency:tree
from the folder of MyProject
is OK: module2 depends on module1
mvn dependency:tree
从文件夹MyProject
是可以的:module2 依赖于 module1
MyProject
---
com.acme:Module1:version
---
com.acme:Module2:version
+com.acme:Module1:version
The problem is if I run mvn dependency:tree
inside the Module2
folder.
I then get the error message:
问题是如果我mvn dependency:tree
在Module2
文件夹内运行。然后我收到错误消息:
The POM for com.acme:Module2:version is invalid,
transitive dependencies (if any) will not be available
After a few investigations I have discovered that the pomfile created/copied by the install part of the build as m2/com/acme/myproject/Module1/version/Module1-version.pom
is the original pomfile.
This one uses variables for versions as (duplicated in many other modules not listed here) or a system path (no choice to have a system dependency). These variables are defined in the parent POM file.
If I replace all the ${}
in the module pomfile by their values then everything is fine.
Basically when building the whole thing, the values of the variables are available to all the dependent modules as this is the same process. When you build an individual module the variables defined in the parent POM are not available.
一些调查后,我已经发现,POM文件创建/编译安装的一部分原样复制m2/com/acme/myproject/Module1/version/Module1-version.pom
是原来的POM文件。这个版本使用变量作为版本(在此处未列出的许多其他模块中重复)或系统路径(没有选择具有系统依赖性)。这些变量在父 POM 文件中定义。如果我用它们的值替换${}
模块pom文件中的所有内容,那么一切都很好。基本上在构建整个过程时,变量的值可用于所有依赖模块,因为这是相同的过程。当您构建单个模块时,父 POM 中定义的变量不可用。
Your own framework pom file contains a variable for the systempath of net.sf.javaml
.
Hardcode the variable or find another solution like a bill of material.
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
您自己的框架 pom 文件包含一个用于net.sf.javaml
. 对变量进行硬编码或找到另一个解决方案,例如物料清单。
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
回答by LCoelho
I had a similar error, In my case remove all related artifacts from the local repository was the workaround...
我有一个类似的错误,在我的情况下,从本地存储库中删除所有相关的工件是解决方法......
回答by D Drummond
Assuming that the client and server projects poms are invalid because of unsatisfied expansion, then the following should work... If the "client" and "server" projects have their dependency on "Framework" defined in a tag, then you can first install "Framework" using the -N option. First, cd to the Framework directory, then:
mvn -N clean install
The -N option tells maven to only install the root pom in the local repo and to skip the child modules. Now cd to your child project and rerun your install command in your client or server module. The client or server build should now find the parent pom with the properties that it needs in the local repo.
假设客户端和服务端项目poms因为扩展不满足而无效,那么下面应该可以工作......如果“客户端”和“服务端”项目对标签中定义的“框架”有依赖,那么你可以先安装使用 -N 选项的“框架”。首先, cd 到 Framework 目录,然后:
mvn -N clean install
-N 选项告诉 maven 只在本地 repo 中安装 root pom 并跳过子模块。现在 cd 到您的子项目并在您的客户端或服务器模块中重新运行您的安装命令。客户端或服务器构建现在应该在本地存储库中找到具有所需属性的父 pom。
You can get the same effect by making an explicit file path reference using the relativePath tag in your child pom's parent tag:
您可以通过在子 pom 的父标记中使用 relativePath 标记进行显式文件路径引用来获得相同的效果:
<parent>
<relativePath>../my-parent</relativePath>
</parent>
回答by awsome
I had the same issue. I am managing all the modules that were referenced by the project that i was trying to build. And the problem turned out that i had to do "mvn deploy" on all the parent projects of the module that was showing this error when using in another modules pom.xml. Here is the whole explanation http://programtalk.com/java/i-used-to-get-this-maven-error-all-time/
我遇到过同样的问题。我正在管理我试图构建的项目引用的所有模块。问题是我必须对在另一个模块 pom.xml 中使用时显示此错误的模块的所有父项目执行“mvn deploy”。这是整个解释http://programtalk.com/java/i-used-to-get-this-maven-error-all-time/
回答by Anas Lachheb
Remove repository folder inside .m2 and launch mvn clean install.
删除 .m2 中的存储库文件夹并启动 mvn clean install。
Keep us informed by the result and Good luck
让我们了解结果并祝你好运
回答by Omri Spector
One reason for this is when you rely on a project for which the parent pom is outdated. This often happens if you are updating the parent pom without installing/deploying it.
原因之一是当您依赖父 pom 已过时的项目时。如果您在没有安装/部署它的情况下更新父 pom,这通常会发生。
To see if this is the case, just run with mvn dependency:tree -X
and search for the exact error. It will mention it misses things you know are in the parent pom, not in the artifact you depend on (e.g. a jar version).
要查看是否是这种情况,只需运行mvn dependency:tree -X
并搜索确切的错误。它会提到它错过了你知道在父 pom 中的东西,而不是你依赖的工件(例如 jar 版本)。
The fix is pretty simple: install the parent pom using mvn install -N
and re-try
修复非常简单:使用安装父 pommvn install -N
并重新尝试
回答by Oscar Javier Gonzalez Hernande
You must to send output to log file with this command:
您必须使用以下命令将输出发送到日志文件:
mvn clean install --log-file C:\XXXX\Maven\log.txt
mvn clean install --log-file C:\XXXX\Maven\log.txt
open log.txt and analize what dependencies are not found or pom.xml are in not valid state
打开 log.txt 并分析哪些依赖项未找到或 pom.xml 处于无效状态
remove pom's that are not valid and re run mvn clean install
删除无效的 pom 并重新运行 mvn clean install
that is all.
就这些。
回答by Владимир Смирнов
In my case maven corrupted one of transitive dependency pom (double content), so I just removed it in my m2 folder. -X key helped me to find the certain broken pom.
在我的情况下,maven 损坏了一个传递依赖 pom(双内容),所以我只是在我的 m2 文件夹中删除了它。-X 键帮助我找到了某些损坏的 pom。
回答by Lucky
For me the pom.xml contents load from a repository to the .m2 folder and the contents of the file when I opened was HTML content which was the reason why I was getting this WARNING message because the site was moved to a different repository location,
对我来说,pom.xml 内容从存储库加载到 .m2 文件夹,打开时文件的内容是 HTML 内容,这就是我收到此警告消息的原因,因为该站点已移至不同的存储库位置,
[WARNING] The POM for GROUPID:ARTIFACTID:PACKAGIN:VERSION is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
So I modified the pom.xml contents to,
所以我将 pom.xml 内容修改为,
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GROUPID</groupId>
<artifactId>ARTIFACTID</artifactId>
<version>VERSION</version>
<packaging>PACKAGIN</packaging>
</project>
Now if I run mvn clean install on the module which had the above dependency the warning din't show. So check the contents of the pom.xml.
现在,如果我在具有上述依赖项的模块上运行 mvn clean install 警告不会显示。所以检查 pom.xml 的内容。