起因
由於公司原因,很多jar包都是內部開源,外部非開源情況,所以很多jar包都在aliyun的遠程倉庫中找不到。但是又因為回家后,自己寫的很多demo都是用的一些公司倉庫里沒有的jar。所以就想着配置多個Maven倉庫鏡像地址,從而解決反復切換倉庫一問題。
<mrrior></mrrior>配置多個鏡像問題
這里必須要提醒!mrrior標簽配置多個,生效的只有第一個!只有第一個倉庫無法訪問的時候,才會使用第二個。注意是無法訪問的時候,如果能訪問,但是倉庫中沒有你要找的包,他不會去訪問第二個倉庫!
<profile></profile>配置多鏡像
這里推薦使用profile屬性進行多鏡像配置。
<profiles> <profile> <!-- id必須唯一 --> <id>aliyunRepository</id> <repositories> <repository> <!-- id必須唯一 --> <id>myRepository1_1</id> <!-- 倉庫的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>companyRepository</id> <repositories> <repository> <!-- id必須唯一 --> <id>myRepository2_1</id> <!-- 倉庫的url地址 --> <url>你們另一個倉庫的地址</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <!-- 激活myRepository2 --> <activeProfile>companyRepository</activeProfile> <!-- 激活myRepository1 --> <activeProfile>aliyunRepository</activeProfile> </activeProfiles>