maven配置本地和阿里云镜像仓库

全局配置方法:

setting.xml

setting.xml


<?xml version="1.0" encoding="UTF-8"?>

<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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  
	<localRepository>/Users/hnu-repo</localRepository>
  -->
  
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    
  </proxies>

  
  <servers>
    
    <server>
      <id>hnu</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>hnu</id>
      <name>hnu</name>
      <url>私服地址</url>
      <mirrorOf>*</mirrorOf>
    </mirror>

    <mirror>
      <id>aliyun</id>
      <name>aliyun</name>
      <url>http://私服地址/nexus/content/repositories/alibaba/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>



    <!-- <mirror>
      <id>aliyun</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>*</mirrorOf>        
    </mirror> -->
	 
  </mirrors>

  <profiles>
    <profile>  
      <id>nexus</id>  
      <repositories>
        <repository>
          <id>hnu</id>
          <url>http://私服地址/nexus/content/groups/public/</url>
        </repository>
        <repository>
          <id>aliyun</id>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>
      </repositories>

      <pluginRepositories>  
        <pluginRepository>  
          <id>hnu</id>  
          <url>http://私服地址/nexus/content/groups/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </pluginRepository>
        <pluginRepository>  
          <id>aliyun</id>  
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>  
    
    <!--
      <activation>  
        <jdk>spring plugins</jdk>  
      </activation>  
    
      <pluginRepositories>  
        <pluginRepository>  
          <id>spring plugins</id>  
          <name>Spring plugins</name>  
          <url>https://maven.aliyun.com/repository/spring-plugin</url> 
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>  
        </pluginRepository>  
      </pluginRepositories>  
      -->
    </profile>  
    

    <profile>
      <id>jdk-1.8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>
    </profile>
  </profiles>

  <activeProfiles>
        <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

 

局部配置(项目):

pom.xml

<repositories>
        <repository>
            <id>hnu</id>
            <name>hnu</name>
            <layout>default</layout>
            <url>私服地址</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一一可可

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值