且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

maven - 如何解决此错误:“XXX的POM无效”?

更新时间:2022-10-31 18:17:27

这听起来像依赖没有正确下载。我会尝试从您的本地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.