maven配置多個(gè)倉(cāng)庫(kù)的實(shí)現(xiàn)
說明
maven的中央倉(cāng)庫(kù)很強(qiáng)大,絕大多數(shù)的jar都收錄了。但也有未被收錄的。遇到未收錄的jar時(shí),就會(huì)編譯報(bào)錯(cuò)。
除了maven官方提供的倉(cāng)庫(kù)之外,也有很多的倉(cāng)庫(kù)。盡可能的將可信的倉(cāng)庫(kù)(嗯,可信的倉(cāng)庫(kù)!)添加幾個(gè),彌補(bǔ)maven官方倉(cāng)庫(kù)的不足。
多倉(cāng)庫(kù)配置方式一:全局多倉(cāng)庫(kù)設(shè)置
全局多倉(cāng)庫(kù)設(shè)置,是通過修改maven的setting文件實(shí)現(xiàn)的。
設(shè)置思路:在setting文件中添加多個(gè)profile(也可以在一個(gè)profile中包含很多個(gè)倉(cāng)庫(kù)),并激活(即使是只有一個(gè)可用的profile,也需要激活)。
修改maven的setting文件,設(shè)置兩個(gè)倉(cāng)庫(kù)(以此類推,可以添加多個(gè)):
? <profiles> ? ? <profile> ? ? ? ? <!-- id必須唯一 --> ? ? ? ? <id>myRepository1</id> ? ? ? ? <repositories> ? ? ? ? ? ? <repository> ? ? ? ? ? ? ? ? <!-- id必須唯一 --> ? ? ? ? ? ? ? ? <id>myRepository1_1</id> ? ? ? ? ? ? ? ? <!-- 倉(cāng)庫(kù)的url地址 --> ? ? ? ? ? ? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url> ? ? ? ? ? ? ? ? <releases> ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled> ? ? ? ? ? ? ? ? </releases> ? ? ? ? ? ? ? ? <snapshots> ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled> ? ? ? ? ? ? ? ? ? ? <updatePolicy>always</updatePolicy> ? ? ? ? ? ? ? ? </snapshots> ? ? ? ? ? ? </repository> ? ? ? ? </repositories> ? ? </profile> ? ? <profile> ? ? ? ? <!-- id必須唯一 --> ? ? ? ? <id>myRepository2</id> ? ? ? ? <repositories> ? ? ? ? ? ? <repository> ? ? ? ? ? ? ? ? <!-- id必須唯一 --> ? ? ? ? ? ? ? ? <id>myRepository2_1</id> ? ? ? ? ? ? ? ? <!-- 倉(cāng)庫(kù)的url地址 --> ? ? ? ? ? ? ? ? <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> ? ? ? ? ? ? ? ? <releases> ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled> ? ? ? ? ? ? ? ? </releases> ? ? ? ? ? ? ? ? <snapshots> ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled> ? ? ? ? ? ? ? ? ? ? <updatePolicy>always</updatePolicy> ? ? ? ? ? ? ? ? </snapshots> ? ? ? ? ? ? </repository> ? ? ? ? </repositories> ? ? </profile> ? </profiles> ? <activeProfiles> ? ? <!-- 激活myRepository1 --> ? ? <activeProfile>myRepository1</activeProfile> ? ? <!-- 激活myRepository2 --> ? ? <activeProfile>myRepository2</activeProfile> ? </activeProfiles>
多倉(cāng)庫(kù)配置方式二:在項(xiàng)目中添加多個(gè)倉(cāng)庫(kù)
在項(xiàng)目中添加多個(gè)倉(cāng)庫(kù),是通過修改項(xiàng)目中的pom文件實(shí)現(xiàn)的。
思路:在項(xiàng)目中pom文件的repositories節(jié)點(diǎn)(如果沒有手動(dòng)添加)下添加多個(gè)repository節(jié)點(diǎn),每個(gè)repository節(jié)點(diǎn)是一個(gè)倉(cāng)庫(kù)。
修改項(xiàng)目中pom文件,設(shè)置兩個(gè)倉(cāng)庫(kù)(以此類推,可以添加多個(gè)):
? ? <repositories> ? ? ? ? <repository> ? ? ? ? ? ? <!-- id必須唯一 --> ? ? ? ? ? ? <id>jboss-repository</id> ? ? ? ? ? ? <!-- 見名知意即可 --> ? ? ? ? ? ? <name>jboss repository</name> ? ? ? ? ? ? <!-- 倉(cāng)庫(kù)的url地址 --> ? ? ? ? ? ? <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> ? ? ? ? </repository> ? ? ? ? <repository> ? ? ? ? ? ? <!-- id必須唯一 --> ? ? ? ? ? ? <id>aliyun-repository</id> ? ? ? ? ? ? <!-- 見名知意即可 --> ? ? ? ? ? ? <name>aliyun repository</name> ? ? ? ? ? ? <!-- 倉(cāng)庫(kù)的url地址 --> ? ? ? ? ? ? <url>http://maven.aliyun.com/nexus/content/groups/public/</url> ? ? ? ? </repository> ? ? </repositories>
注:以上兩種方式的id值均不可以為“central”。
到此這篇關(guān)于maven配置多個(gè)倉(cāng)庫(kù)的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)maven 多個(gè)倉(cāng)庫(kù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBootTest測(cè)試時(shí)不啟動(dòng)程序的問題
這篇文章主要介紹了SpringBootTest測(cè)試時(shí)不啟動(dòng)程序的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-01-01
springboot整合redis實(shí)現(xiàn)發(fā)送郵箱并驗(yàn)證
大家好,本篇文章主要講的是springboot整合redis實(shí)現(xiàn)發(fā)送郵箱并驗(yàn)證,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下2022-01-01
Java使用Ajax實(shí)現(xiàn)跨域上傳圖片功能
這篇文章主要介紹了Java使用Ajax實(shí)現(xiàn)跨域上傳圖片功能,需要的朋友可以參考下2017-09-09
java數(shù)組及arrays類對(duì)數(shù)組的操作實(shí)例
下面小編就為大家?guī)硪黄猨ava數(shù)組及arrays類對(duì)數(shù)組的操作實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-10-10
接口隔離原則_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要介紹了接口隔離原則,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08
Java在ElasticSearch中使用LocalDatetime類型
最近在開發(fā)一個(gè)搜索功能的需求的時(shí)候,遇到了LocalDatetime類型不能保存到ElasticSearch中的問題,這篇文章主要介紹了Java在ElasticSearch中使用LocalDatetime類型2023-10-10

