自学内容网 自学内容网

【maven】配置下载私有仓库的快照版本

1、setting.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
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>/root/.m2/repository</localRepository>
  
  <servers>
    <server>
      <id>dev-maven</id>
      <username>admin</username>
      <password>xxxx</password>
    </server>
  </servers>


  <mirrors>
    <mirror>      
      <id>dev-maven</id>
      <name>dev-maven</name>
      <mirrorOf>*</mirrorOf>   <!-- 这个要配置 *,配置maven的中央地址的话,不行-->
      <url>http://xx.xx.xx.22/nexus/repository/maven-public/</url>
    </mirror>
  </mirrors>


  <profiles>
    <profile>
    <id>dev-maven</id>
    <repositories>
        <repository>
            <id>dev-maven</id>
            <name>dev-maven</name>
            <url>http://xx.xx.xx.22/nexus/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>  <!-- 开启这个配置true,允许下载快照版本-->
            </snapshots>
        </repository>
    </repositories>
   </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>dev-maven</activeProfile>
  </activeProfiles>


</settings>

2、POM.xml文件配置

  <repositories>
    <repository>
      <id>dev-maven</id>
      <name>dev-maven</name>
      <url>http://xxx.xxx.xx.22/nexus/repository/maven-public/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>


原文地址:https://blog.csdn.net/binqian/article/details/144036114

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!