我正在重新配置其他人很久以前设置的构建服务器以使用新的 Maven 存储库。但是,旧存储库仍在被引用,我无法弄清楚该引用来自哪里。
M2_HOME=/usr/share/maven2
/etc/maven2/m2.conf(usr/share/maven2/conf/m2.conf 链接在此)
main is org.apache.maven.cli.MavenCli from plexus.core
set maven.home default ${user.home}/m2
[plexus.core]
load ${maven.home}/lib/*.jar
/etc/maven2/conf 还有一个 settings.xml,其中所有条目都被注释掉。
构建用户有一个~/.m2/settings.xml:引用NewRepo。
<settings>
<pluginGroups>
</pluginGroups>
<servers>
</servers>
<profiles>
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<id>personal</id>
<repositories>
<repository>
<id>new-repo</id>
<name>New Maven 2 Repo</name>
<url>http://NewRepo/</url>
</repository>
<!-- Some other standard repos like maven.org here -->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ibiblio</id>
<name>Ibiblio Maven 2 Repo</name>
<url>http://repo1.maven.org/maven2/</url>
</pluginRepository>
<pluginRepository>
<id>apache-snapshots</id>
<name>Apache Snapshots Maven 2 Repo</name>
<url>http://people.apache.org./maven-snapshot-repository/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
还有一个/mnt/public/maven/settings.xml,其内容与构建用户的settings.xml完全相同
我搜索了整个文件系统以确保没有其他 settings.xml 文件。
运行时
mvn release:prepare
我收到警告:
[INFO] NOTE: Maven is executing in offline mode. Any artifacts not already in your local repository will be inaccessible.
运行时
mvn release:perform
我收到错误:
Error deploying artifact: Failed to transfer file: http://OldRepo
对 http://OldRepo 的引用可能隐藏在哪里?
编辑
项目的 pom.xml 引用父 POM,如下所示:
<parent>
<groupId>MyParent</groupId>
<artifactId>maven</artifactId>
<version>20090727</version>
</parent>
没有引用
<distributionManagement>
在项目的 POM 中。我无法找到父 POM。
最佳答案
关于repositories
在 settings.xml
中声明的 profile
内,文档显示:
Repositories are remote collections of projects from which Maven uses to populate the local repository of the build system. It is from this local repository that Maven calls it plugins and dependencies. Different remote repositories may contain different projects, and under the active profile they may be searched for a matching release or snapshot artifact.
所以这不用于发布管理。要配置工件的部署位置,您需要在 pom 中添加 distributionManagement
元素。
以下是如何在项目 pom.xml 文件中配置 distributionManagement
元素的示例。
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Application</name>
<url>http://app.mycompany.com</url>
...
<distributionManagement>
<repository>
<id>myRepoId</id>
<name>myCompanyReporsitory</name>
<url>ftp://repository.mycompany.com/repository</url>
</repository>
</distributionManagement>
...
</project>
在您的 pom 或父 pom 中查找此元素(可以在公司父 pom 中声明它)。
编辑:您可以覆盖 pom 中的 distributionManagement
但最好在父 pom 中修改它并在企业存储库中发布此新版本(如果出现这种情况)是一个决定性的改变。
关于maven-2 - Maven 存储库位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1590485/