“ POM for... 丢失了,没有可用的依赖信息”,即使它存在于 Maven Repository 中

问题:

即使我从 MavenRepository 复制了依赖项,依赖项也不会下载。

当我将鼠标悬停在 Eclipse 中的依赖项上时,它会发出警告: “ Maven Missing artifact org.raml:jaxrs-code-generator:jar:2.0.0”。

当我尝试 mvn installmvn compile时,它会发出警告: “ [WARNING] The POM for org.raml:jaxrs-code-generator:jar:2.0.0 is missing, no dependency information available”。

试过:

  • 罐子下载到 ~/.m2/repository/org/raml/jaxrs-code-generator/2.0.0文件夹中,然后在编辑器中刷新。

    • 当我 installcompile时,它似乎忽略了它。
  • 运行 mvn -U

    • installcompile相同。

深度:

    <dependency>
<groupId>org.raml</groupId>
<artifactId>jaxrs-code-generator</artifactId>
<version>2.0.0</version>
</dependency>
  • Maven 仓库中的依赖项 存在(版本也是正确的)。

  • 使用 Eclipse EE Neon 4.6.3、 Apache Maven 3.3.9、 Java 1.8.0 _ 121。

  • ~/.m2文件夹中没有 settings.xml

  • 我不使用任何其他存储库,无论是本地的还是其他的。

199789 次浏览

You will need to add external Repository to your pom, since this is using Mulsoft-Release repository not Maven Central

<project>
...
<repositories>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
...
</project>

Dependency

Apache Maven - Setting up Multiple Repositories

Read carefully the warning message :

The POM for org.raml:jaxrs-code-generator:jar:2.0.0 is missing, no dependency information available

The problem is not the jar, but the pom.xml that is missing.
The pom.xml lists the required dependencies for this jar that Maven will pull during the build and overall the packaging of your application. So, you may really need it.

Note that this problem may of course occur for other Maven dependencies and the ideas to solve that is always the same.

The Mule website documents very well that in addition to some information related to.


How to solve ?

1) Quick workaround : looking for in the internet the pom.xml of the artifact

Googling the artifact id, the group id and its version gives generally interesting results : maven repository links to download it.
In the case of the org.raml:jaxrs-code-generator:jar:2.0.0 dependency, you can download the pom.xml from the Maven mule repository :

https://repository.mulesoft.org/nexus/content/repositories/releases/org/raml/jaxrs-code-generator/2.0.0/

2) Clean workaround for a single Maven project : adding the repository declaration in your pom.

In your case, add the Maven mule repositories :

<?xml version="1.0" encoding="UTF-8"?>
<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>
...
<repositories>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshot Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
</repositories>
...
</project>

3) Clean workaround for any Maven projects : add the repository declaration in your settings.xml

 <profile>
<repositories>
...
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshot Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
...
</repositories>
</profile>

Note that in some rare cases, the pom.xml declaring the dependencies is nowhere. So, you have to identify yourself whether the artifact requires dependencies.

In my case I was using Jade and I was using HTTP repository URL. Changing the Url to HTTPS worked for me.

This is my solution, may be it can helps I use IntelliJ IDE. File -> Setting -> Maven -> Importing change JDK for importer to 1.8( you can change to lower, higher)

I had a similar problem quite recently. In my case:

  1. I downloaded an artifact from some less popular Maven repo

  2. This repo dissappeared over this year

  3. Now builds fail, even if I have this artifact and its pom.xml in my local repo

Workaround:

delete _remote.repositories file in your local repo, where this artifact resides. Now the project builds.

In my case the reason was since the remote repo artifact (non-central) had dependencies from the Maven Central in the .pom file, and the older version of mvn (older than 3.6.0) was used. So, it tried to check the Maven Central artifacts mentioned in the remote repo's .pom for the specific artifact I've added to my dependencies and faced the Maven Central http access issue behind the scenes (I believe the same as described there: Maven dependencies are failing with a 501 error - that is about using https access to Maven Central by default and prohibiting the http access).

Using more recent Maven (from 3.1 to 3.6.0) made it use https to check Maven Central repo dependencies mentioned in the .pom files of the remote repositories and I no longer face the issue.

If the POM missing warning is of project's self module, the reason is that you are trying to mistakenly build from a sub-module directory. You need to run the build and install command from root directory of the project.

Problem is not with the jar file. Maven is unable to fetch the correct meta data.

Delete the _maven.repositories or _remote.repositories (one of those files will be there) file and build again. Files are located in .m2/repository/path/to/your/repo/

Could also be you have enabled: Work offline. In the intellij Maven -> Importing settings.

This was the case for me, I forgot I had this setting enabled.

Another option that can help is to reload the dependencies with

mvn dependency:resolve -U

I had the same error but not in the same use case. For me i use a multi modules project. But i use mvn clean package to compile some maven module, in other maven module it display the same error. My solution is that i should use mvn clean install instead of mvn clean package

package: will compile your code and also package it. For example, if your pom says the project is a jar, it will create a jar for you when you package it and put it somewhere in the target directory (by default).

install: will compile and package, but it will also put the package in your local repository. This will make it so other projects can refer to it and grab it from your local repository.

Search in the repository like https://search.maven.org/ that which version of the package is available.

In some cases, the latest version may not be available in the repo.