maven - How to solve this error : “The POM for XXX is invalid”?

时间秒杀一切 提交于 2019-12-11 01:31:58

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/20150226/maven-how-to-solve-this-error-the-pom-for-xxx-is-invalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!