亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

內(nèi)網(wǎng)搭建maven倉庫 maven配置多個遠程倉庫

Maven是Java的項目配置管理工具 , 用來管理依賴,具體的用途就不展開說了 。大部分項目,配置一個鏡像倉庫地址就可以了(單個mirror) 。但是有的網(wǎng)上下載的項目需要從多個倉庫查找對應的包,從網(wǎng)上找了很多帖子,配置Maven的settings.xml文件中的多個倉庫,都是從一個地方復制粘貼的,方法說的都不對 。今天自己研究了一下,分享給大家 。
最終的settings.xml文件配置如果你不想看具體的配置,可以直接把我下面這個配置拿走,修改一下localRepository部分對應自己的本地repo(通常為~/.m2/repository) , 然后將settings.xml替換${MAVEN_HOME}/conf/settings.xml即可 。
<?xml version="1.0" encoding="UTF-8"?><settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd"><localRepository>/Users/chris/.m2/repository</localRepository><pluginGroups></pluginGroups><proxies></proxies><servers></servers><mirrors></mirrors><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>pentaho</id><repositories><repository><id>pentaho</id><url>https://nexus.pentaho.org/content/repositories/omni/</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>repo2</id><repositories><repository><id>repo2</id><url>https://repo2.maven.org/maven2</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories></profile></profiles><activeProfiles><activeProfile>aliyun</activeProfile><activeProfile>pentaho</activeProfile><activeProfile>repo1</activeProfile><activeProfile>repo2</activeProfile></activeProfiles></settings>settings.xml相關具體配置介紹Mirrors標簽部分通常用來定義鏡像倉庫(repository),指定用來下載對應依賴和插件的倉庫地址 。使用Mirrors的理由如下:

  • 配置一個就近加速的網(wǎng)絡倉庫;
  • 配置一個你本地創(chuàng)建的鏡像倉庫;
來自Maven官方的Mirrors配置示例如下:
<settings>...<mirrors><mirror><id>other-mirror</id><name>Other Mirror Repository</name><url>https://other-mirror.repo.other-company.com/maven2</url><mirrorOf>central</mirrorOf></mirror></mirrors>...</settings>在Mirrors部分可以配置多個鏡像倉庫,但是在該部分配置多個倉庫,并不能提供自動查詢多個倉庫的功能 , 默認還是取第一個倉庫進行查詢 。
Profiles標簽部分settings.xml中的profile部分,包括4個二級子標簽:activation, repositories, pluginRepositories and properties 。profile部分的內(nèi)容需要在下面進行激活 。這里介紹多個鏡像共同使用僅介紹Repositories部分 。
Repositories配置方式如下,指定repo地址、id:
<profiles><profile><id>repo2</id><repositories><repository><id>repo2</id><url>https://repo2.maven.org/maven2</url><releases><enabled>true</enabled></releases><snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots></repository></repositories></profile></profiles>Active Profiles標簽部分settings.xml配置文件最后的一部分就是激活公用多個倉庫的重點activeProfiles 。包含多個activeProfile元素,每一個activeProfile元素都用來指定一個上部分profile的id,也就是說,每指定一個activeProfile映射 , 就激活一個profile,將會覆蓋其他任何環(huán)境配置 。
大家從如下例子里,可以看到我配置了aliyun、pentaho、repo1和repo2四個倉庫,這樣再執(zhí)行mvn命令,他就會從這四個倉庫循環(huán)去查找包 , 第一個找不到就去第二個找 。。。
【內(nèi)網(wǎng)搭建maven倉庫 maven配置多個遠程倉庫】<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">...<activeProfiles><activeProfile>aliyun</activeProfile><activeProfile>pentaho</activeProfile><activeProfile>repo1</activeProfile><activeProfile>repo2</activeProfile></activeProfiles></settings>


    以上關于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關的問題,請您及時就醫(yī)或請專業(yè)人士給予相關指導!

    「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助: