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

我已经配置了父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下载.为了您的信息,我在我的内部仓库中配置了所有插件.

最佳答案 我在.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都要好得多.

点赞