Java 缺少项目的 POM,没有可用的依赖信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18732175/
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 project is missing, no dependency information available
提问by Dave Jarvis
Background
背景
Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added:
尝试使用全新安装的 Apache Maven 3.1.0 和 Java 1.7 将 Java 库添加到本地 Maven 存储库。以下是添加 Java 存档文件的方式:
mvn install:install-file \
-DgroupId=net.sourceforge.ant4x \
-DartifactId=ant4x \
-Dversion=0.3.0 \
-Dfile=ant4x-0.3.0.jar \
-Dpackaging=jar
This created the following directory structure:
这创建了以下目录结构:
$HOME/.m2/repository/net/sourceforge/ant4x/
├── 0.3.0
│ ├── ant4x-0.3.0.jar.lastUpdated
│ └── ant4x-0.3.0.pom.lastUpdated
└── ant4x
├── 0.3.0
│ ├── ant4x-0.3.0.jar
│ ├── ant4x-0.3.0.pom
│ └── _remote.repositories
└── maven-metadata-local.xml
The project's pom.xml
file references the dependent project (the tree above) as follows:
项目的pom.xml
文件引用依赖项目(上面的树)如下:
<properties>
<java-version>1.5</java-version>
<net.sourceforge.ant4x-version>0.3.0</net.sourceforge.ant4x-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Problem
问题
After running mvn compile
, the following error was returned (full log on Pastebin):
运行后mvn compile
,返回以下错误(在 Pastebin 上完整登录):
[ERROR] Failed to execute goal on project ant4docbook: Could not resolve dependencies for project net.sourceforge:ant4docbook:jar:0.6-SNAPSHOT: Failure to find net.sourceforge:ant4x:jar:0.3.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
The documentationnotes a number of issues that could be present, however none of these appear to apply.
该文档指出了许多可能存在的问题,但这些问题似乎都不适用。
Ideas
想法
I tried the following, as per the documentation:
根据文档,我尝试了以下操作:
- Copy default settings to user's home directory for Maven:
cp /opt/apache-maven-3.1.0/conf/settings.xml $HOME/.m2/.
- Edit the user's settings.xml file.
- Update the value for the local repository:
${user.home}/.m2/repository
- Save the file.
- 将默认设置复制到 Maven 的用户主目录:
cp /opt/apache-maven-3.1.0/conf/settings.xml $HOME/.m2/.
- 编辑用户的 settings.xml 文件。
- 更新本地存储库的值:
${user.home}/.m2/repository
- 保存文件。
I also tried the following commands:
我还尝试了以下命令:
mvn -U
mvn clear -U
I tried using Maven 3.0.5, but that failed, too.
我尝试使用 Maven 3.0.5,但也失败了。
Question
题
How do you force Maven to use the local version of the library, rather than trying to seek out a library that is not yet available to download?
您如何强制 Maven 使用库的本地版本,而不是尝试寻找尚未可供下载的库?
Related
有关的
Related questions and information that did not resolve the issue:
未解决问题的相关问题和信息:
- The POM for org.springframework.security:org.springframework.security.web:jar:3.0.5.RELEASE is missing, no dependency information available
- How can I locate the POM which requests a missing POM?
- Maven: Including jar not found in public repository
- http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
- http://giallone.blogspot.ca/2012/12/maven-install-missing-offline.html
采纳答案by Dave Jarvis
Change:
改变:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
To:
到:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
The groupId
of net.sourceforge
was incorrect. The correct value is net.sourceforge.ant4x
.
的groupId
的net.sourceforge
是不正确的。正确的值为net.sourceforge.ant4x
。
回答by Gyanendra Dwivedi
The scope <scope>provided</scope>
gives you an opportunity to tell that the jar would be available at runtime, so do not bundle it. It does not mean that you do not need it at compile time, hence maven would try to download that.
作用域<scope>provided</scope>
使您有机会告诉您 jar 将在运行时可用,因此不要捆绑它。这并不意味着您在编译时不需要它,因此 maven 会尝试下载它。
Now I think, the below maven artifact do not exist at all. I tries searching google, but not able to find. Hence you are getting this issue.
现在我认为,下面的 maven 神器根本不存在。我尝试搜索谷歌,但无法找到。因此,您遇到了这个问题。
Change groupId
to <groupId>net.sourceforge.ant4x</groupId>
to get the latest jar.
更改groupId
为<groupId>net.sourceforge.ant4x</groupId>
获取最新的jar。
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Another solution for this problem is:
这个问题的另一个解决方案是:
- Run your own maven repo.
- download the jar
- Install the jar into the repository.
- Add a code in your pom.xml something like:
- 运行你自己的 Maven 仓库。
- 下载罐子
- 将 jar 安装到存储库中。
- 在 pom.xml 中添加如下代码:
Where http://localhost/repois your local repo URL:
其中http://localhost/repo是您的本地存储库 URL:
<repositories>
<repository>
<id>wmc-central</id>
<url>http://localhost/repo</url>
</repository>
<-- Other repository config ... -->
</repositories>