背景
尝试使用全新安装的 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
这创建了以下目录结构:
$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
项目的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>
问题
运行mvn compile
后,返回如下错误(full log on 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]
documentation注意到一些可能存在的问题,但这些问题似乎都不适用。
想法
根据文档,我尝试了以下方法:
- 将默认设置复制到用户的 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.
I also tried the following commands:
mvn -U
mvn clear -U
我尝试使用 Maven 3.0.5,但也失败了。
问题
您如何强制 Maven 使用本地版本的库,而不是尝试寻找尚未提供下载的库?
相关
未能解决问题的相关问题和信息:
- 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
最佳答案
变化:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
收件人:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
net.sourceforge
的groupId
不正确。正确的值是 net.sourceforge.ant4x
。
关于java - 项目的 POM 丢失,没有可用的依赖信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18732175/