在我阅读之后,我完全无法得出结论,为什么有必要更改为了使用maven从我的archiva存储库下载工件的内容。
我在服务器上设置了archiva,并且我正在尝试运行一个简单的maven项目,该项目将获取我的archiva repo中的工件并下载它们。
我要更改哪个settings.xml?服务器或本地副本上的那个?
是否需要更改pom.xml?
答案 0 :(得分:1)
您的本地~/.m2/settings.xml
文件(或Windows下的%USERPROFILE%\.m2\setting.xml
)。在那里你可以设置:
<mirrors>
<mirror>
<id>yourrepo-id</id>
<name>yourrepo-name</name>
<url>http://yourrepo/archiva</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
或者,您可以添加<profile/>
<activeByDefault>true</activeByDefault>
并在其中添加<repositories>
/ <pluginRepositories>
。
<?xml version="1.0"?>
<settings>
<profiles>
<profile>
<id>add-repositories</id>
<activation>
<!-- Make the profile active by default -->
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<!-- Each repository should have and id -->
<id>snapshots</id>
<snapshots>
<!-- This repository contains snapshots and Maven should always check for the latest version -->
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<!-- No releases are stored here: only snapshots -->
<enabled>false</enabled>
</releases>
<!-- The URL -->
<url>http://yourrepo/snashots</url>
</repository>
<repository>
<!-- For releases -->
<id>releases</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>http://yourrepo/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
<!-- The URL -->
<url>http://yourrepo/snashots</url>
</pluginRepository>
<pluginRepository>
<!-- For releases -->
<id>releases</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>http://yourrepo/releases</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- mirrors, servers and other sections -->
</settings>
或者,您可以更改pom.xml
并添加相应的<repositories/>
和/或<pluginRepositories/>
部分。
<project ...>
<repositories>
<repository>
<!-- Each repository should have and id -->
<id>snapshots</id>
<snapshots>
<!-- This repository contains snapshots and Maven should always check for the latest version -->
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<!-- No releases are stored here: only snapshots -->
<enabled>false</enabled>
</releases>
<!-- The URL -->
<url>http://yourrepo/snashots</url>
</repository>
<repository>
<!-- For releases -->
<id>releases</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>http://yourrepo/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
<!-- The URL -->
<url>http://yourrepo/snashots</url>
</pluginRepository>
<pluginRepository>
<!-- For releases -->
<id>releases</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<url>http://yourrepo/releases</url>
</pluginRepository>
</pluginRepositories>
</project>