maven - 如何解决此错误:“XXX的POM无效”? [英] maven - How to solve this error : "The POM for XXX is invalid"?

查看:2311
本文介绍了maven - 如何解决此错误:“XXX的POM无效”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用maven构建一个简单的项目。我无法找到它,因为传递依赖关系丢失,即 objenesis 1.0



我运行maven处于调试模式,并收到以下消息:

  [DEBUG] ============ ================================================== ======= 
[警告] org.jmock:jmock-junit4:jar:2.6.0的POM无效,传递依赖关系(如果有)不可用:构建时遇到1个问题org.jmock的有效模型:jmock-junit4:2.6.0
[ERROR]父POM org.jmock的无效打包:jmock-parent:2.6.0,必须是pom,而是jar@ org.jmock:jmock-parent:2.6.0
...

当我看在jmock-parent中,我似乎找不到pom或jar类型的引用。



我如何解决这个问题?



Nota:我们使用我们公司的关联来获取依赖关系。






pom.xml

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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> Poc< / groupId>
< artifactId> Poc< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>

< properties>
< maven.compiler.source> 1.6< /maven.compiler.source>
< maven.compiler.target> 1.6< /maven.compiler.target>
< / properties>

<依赖关系>
<依赖关系>
< groupId> org.jmock< / groupId>
< artifactId> jmock-junit4< / artifactId>
< version> 2.6.0< / version>
< / dependency>
< / dependencies>
< / project>

jmock-parent-2.6.0.pom

 <?xml version =1.0encoding =UTF-8?> 
< project xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdxmlns = http://maven.apache.org/POM/4.0.0
xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance>
< modelVersion> 4.0.0< / modelVersion>
< groupId> org.jmock< / groupId>
< artifactId> jmock-parent< / artifactId>
< version> 2.6.0< / version>
< description> POM由Sonatype Nexus< / description>创建。
< / project>


解决方案

这听起来像依赖没有正确下载。我会尝试从您的本地M2存储库中删除org.jmock目录,并让Maven尝试新的下载该jar。



编辑:当您在文本编辑器中查看 M2_REPO\org\jmock\jmock-parent\2.6.0\jmock-parent-2.6.0.pom 具体来说< packaging> pom< / package> ?您可能想确保您的Nexus回购中的依赖关系也是正确的。我刚刚从Maven Central中获取了依赖关系,没有任何问题。





编辑2 :Nexus可能会自动创建一个父类pom如果它不能从Maven Central下载,你就喜欢这样。您的Nexus安装是否配置为从Maven Central下载依赖项?您手动将您的jmock-junit4.jar手动 mvn deploy:deploy-file 到您的Nexus repo?我确定有一种方法来强制Nexus更新该pom,或者您可以通过从maven中心下载然后运行 mvn deploy 命令手动部署正确的父pom


I'm building a simple project with maven. I'm unable to get it to build because a transitive dependencies is missing, namely objenesis 1.0.

I run maven in debug mode and got this message:

[DEBUG] =======================================================================
[WARNING] The POM for org.jmock:jmock-junit4:jar:2.6.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.jmock:jmock-junit4:2.6.0
[ERROR] Invalid packaging for parent POM org.jmock:jmock-parent:2.6.0, must be "pom" but is "jar" @ org.jmock:jmock-parent:2.6.0
...

When I look at jmock-parent I can't seem to find reference to neither pom or jar type.

How can I solve this issue ?

Nota: We use the nexus of our company for fetching dependencies.


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>Poc</groupId>
<artifactId>Poc</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies>
      <dependency>
         <groupId>org.jmock</groupId>
         <artifactId>jmock-junit4</artifactId>
         <version>2.6.0</version>
      </dependency>
</dependencies>
  </project>

jmock-parent-2.6.0.pom

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.jmock</groupId>
   <artifactId>jmock-parent</artifactId>
   <version>2.6.0</version>
   <description>POM was created by Sonatype Nexus</description>
</project>

解决方案

It sounds like the dependency didn't download properly. I would try deleting the org.jmock directory from your local M2 repository and let Maven try a fresh download of that jar.

Edit: When you look at M2_REPO\org\jmock\jmock-parent\2.6.0\jmock-parent-2.6.0.pom in a text editor does it specifically say <packaging>pom</packaging>? You may want to make sure your dependencies in your Nexus repo are correct as well. I just pulled the dependency from Maven Central and didn't have a problem with it.

Edit 2: It's possible that Nexus will automatically create a parent pom for you like that if it can't download it from Maven Central. Is your Nexus installation configured to download dependencies from Maven Central? Did you manually mvn deploy:deploy-file your jmock-junit4.jar to your Nexus repo? I'm sure there's a way to force Nexus to update that pom, or you could manually deploy the proper parent pom by downloading it from maven central and then running the mvn deploy command listed above.

这篇关于maven - 如何解决此错误:“XXX的POM无效”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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