maven setting.xml 配置多个仓库 mirror 不行,得用profiles

<?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">
          

<profiles>
 

   <profile>
       <id>aliyun</id>
       <repositories>
           <repository>
               <id>aliyun</id>
               <url>https://maven.aliyun.com/repository/public</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
               </snapshots>
           </repository>
       </repositories>
   </profile>

   <profile>
       <id>huaweicloud</id>
       <repositories>
           <repository>
               <id>huaweicloud</id>
               <url>https://mirrors.huaweicloud.com/repository/maven/</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
               </snapshots>
           </repository>
       </repositories>
   </profile>

   <profile>
       <id>flink</id>
       <repositories>
           <repository>
               <id>flink</id>
               <url>https://packages.confluent.io/maven/</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
               </snapshots>
           </repository>
       </repositories>
   </profile>

   <profile>
       <id>repo1</id>
       <repositories>
           <repository>
               <id>repo1</id>
               <url>https://repo1.maven.org/maven2</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
               </snapshots>
           </repository>
       </repositories>
   </profile>

   <profile>
       <id>cloudera</id>
       <repositories>
           <repository>
               <id>cloudera</id>
               <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
               </snapshots>
           </repository>
       </repositories>
   </profile>

</profiles>
 
<activeProfiles>
   <activeProfile>aliyun</activeProfile>
   <activeProfile>huaweicloud</activeProfile>
   <activeProfile>flink</activeProfile>
   <activeProfile>repo1</activeProfile>

   <activeProfile>cloudera</activeProfile> 
 </activeProfiles>

</settings>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Maven是一款Java项目管理工具,而setting.xmlMaven配置文件之一,它位于Maven安装目录下的conf文件夹中,用于配置Maven的全局设置、仓库、代理服务器等信息,以及用户自定义的配置信息。下面是setting.xml文件的详细配置介绍: 1. 服务器设置 ``` <servers> <server> <id>server1</id> <username>user1</username> <password>pwd1</password> </server> </servers> ``` 这里定义了一个名为server1的服务器,指定了用户名和密码。 2. 代理服务器设置 ``` <proxies> <proxy> <id>proxy1</id> <active>true</active> <protocol>http</protocol> <host>proxy.example.com</host> <port>8080</port> <username>user1</username> <password>pwd1</password> <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts> </proxy> </proxies> ``` 这里定义了一个名为proxy1的代理服务器,指定了代理服务器的地址、端口、用户名和密码等信息。 3. 仓库设置 ``` <repositories> <repository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> ``` 这里定义了一个名为central的仓库,指定了仓库的地址、是否启用发布版本和快照版本等信息。 4. 插件仓库设置 ``` <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> ``` 这里定义了一个名为central的插件仓库,指定了仓库的地址、是否启用发布版本和快照版本等信息。 5. 全局设置 ``` <settings> <offline>false</offline> <interactiveMode>true</interactiveMode> <usePluginRegistry>true</usePluginRegistry> <offlineCache> <enabled>false</enabled> </offlineCache> <mirrors> <mirror> <id>mirror1</id> <name>mirror1</name> <url>http://mirror1.example.com</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> <profiles> <profile> <id>profile1</id> <repositories> <repository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://central.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>profile1</activeProfile> </activeProfiles> </settings> ``` 这里定义了Maven的全局配置信息,包括是否离线模式、是否交互式模式、是否使用插件注册表等。 以上为setting.xml文件的详细配置介绍,通过配置setting.xml文件,可以更好地控制Maven的行为。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值