如何使Maven使用内部仓库而不是中央Maven仓库?

4
我已经配置了父级pom.xml文件,使用我创建的apache Archiva内部存储库。我的Pom看起来像这样:
<distributionManagement>
  <repository>
    <id>internal</id>
    <url>dav:http://x.x.x.x:9090/archiva/repository/internal</url>
  </repository>
</distributionManagement>

我正在尝试从Hudson执行相同的操作。但是当它尝试下载任何缺失的插件时,仍然会尝试从中央存储库repo1.maven.org下载。供您参考,我已经在我的内部存储库中配置了所有插件。
1个回答

3
我在.m2/settings.xml中使用以下配置将所有请求转发到内部仓库:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                              http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <localRepository>/home/bozhidar/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <offline>false</offline>

  <servers> 
    <server> 
      <id>nexus</id> 
      <username>***</username> 
      <password>***</password> 
    </server> 
  </servers> 

  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>https://xxx/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>  
</settings>

顺便说一下,我曾经使用过Archiva,我建议你尝试使用Sonatype Nexus或Artifactory——它们都是免费的,并且比Archiva好得多。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接