maven配置多個(gè)倉(cāng)庫(kù)的實(shí)現(xiàn)
說(shuō)明
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è)置,是通過(guò)修改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ù),是通過(guò)修改項(xiàng)目中的pom文件實(shí)現(xiàn)的。
思路:在項(xiàng)目中pom文件的repositories節(jié)點(diǎn)(如果沒(méi)有手動(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> ? ? ? ? ? ? <!-- 見(jiàn)名知意即可 --> ? ? ? ? ? ? <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> ? ? ? ? ? ? <!-- 見(jiàn)名知意即可 --> ? ? ? ? ? ? <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)文章
Java Web學(xué)習(xí)之MySQL在項(xiàng)目中的使用方法
mysql數(shù)據(jù)庫(kù)是我們?cè)谌粘i_(kāi)發(fā)中經(jīng)常會(huì)用到的,下面這篇文章主要給大家介紹了關(guān)于Java Web學(xué)習(xí)之MySQL在項(xiàng)目中的使用方法,需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-04-04
lambda表達(dá)式解決java后臺(tái)分組排序過(guò)程解析
這篇文章主要介紹了lambda表達(dá)式解決java后臺(tái)分組排序過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10
JVM?運(yùn)行時(shí)數(shù)據(jù)區(qū)與JMM?內(nèi)存模型
這篇文章主要介紹了JVM?運(yùn)行時(shí)數(shù)據(jù)區(qū)與JMM?內(nèi)存模型,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值。需要的朋友可以參考一下2022-07-07
@ConfigurationProperties遇到的坑及解決
這篇文章主要介紹了解決@ConfigurationProperties遇到的坑,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07
Spring Boot如何使用Undertow代替Tomcat
這篇文章主要介紹了Spring Boot如何使用Undertow代替Tomcat,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09
解決Maven的pom.xml中設(shè)置repository不起作用問(wèn)題
這篇文章主要介紹了解決Maven的pom.xml中設(shè)置repository不起作用問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03

