如何让maven使用Internal Repository而不是使用中央Maven存储库?

时间:2010-08-20 05:21:14

标签: maven-2

我已将父pom.xml配置为使用我用apache Archiva创建的内部存储库。我的Pom看起来像

<distributionManagement>
  <repository>
    <id>internal</id>
    <url>dav:http://x.x.x.x:9090/archiva/repository/internal</url>
  </repository>
</distributionManagement>

我正试图从哈德森那里执行同样的事情。但是当它试图下载任何丢失的插件时,它仍然试图从中央repo1.maven.org下载。为了您的信息,我在我的内部仓库中配置了所有插件。

1 个答案:

答案 0 :(得分:2)

我在.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>
Btw,我过去曾使用过Archiva,我可以推荐你试用Sonatype Nexus或Artifactory - 它们都是免费的,而且比Archiva都好。