maven 配置多個倉庫的方法
1>方法一
之前在配置 Maven 的 settings.xml 時,都會設置 mirror 節(jié)點,例如:
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
然后第一想法就是在 mirrors 節(jié)點下多增加幾個 mirror,然而并不可以。正確的操作是在 profiles 節(jié)點下配置多個 profile,而且配置之后要激活。例如:
配置profiles
<profiles> <profile> <id>boundlessgeo</id> <repositories> <repository> <id>boundlessgeo</id> <url>https://repo.boundlessgeo.com/main/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>aliyun</id> <repositories> <repository> <id>aliyun</id> <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>maven-central</id> <repositories> <repository> <id>maven-central</id> <url>http://central.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profiles>
通過配置 activeProfiles 子節(jié)點激活
<activeProfiles> <activeProfile>boundlessgeo</activeProfile> <activeProfile>aliyun</activeProfile> <activeProfile>maven-central</activeProfile> </activeProfiles>
如果在IDE里,記得要更新生效,然后就可以了。
2> 方法二
在項目中添加多個倉庫,是通過修改項目中的pom文件實現的。
思路:在項目中pom文件的repositories節(jié)點(如果沒有手動添加)下添加多個repository節(jié)點,每個repository節(jié)點是一個倉庫。
<repositories> <repository> <!-- id必須唯一 --> <id>jboss-repository</id> <name>jboss repository</name> <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> </repository> <repository> <id>aliyun-repository</id> <name>aliyun repository</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> <repository> <id>奇葩倉庫</id> <url>https://奇葩倉庫/public/</url> </repository> </repositories>
到此這篇關于maven 配置多個倉庫的方法的文章就介紹到這了,更多相關maven 多個倉庫配置內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
SpringBoot實現Server-Sent Events(SSE)的使用完整指南
使用SpringBoot實現Server-Sent Events(SSE)可以有效處理實時數據推送需求,具有單向通信、輕量級和高實時性等優(yōu)勢,本文詳細介紹了在SpringBoot中創(chuàng)建SSE端點的步驟,并通過代碼示例展示了客戶端如何接收數據,適用于實時通知、數據展示和在線聊天等場景2024-09-09SpringBoot使用thymeleaf實現一個前端表格方法詳解
Thymeleaf是一個現代的服務器端 Java 模板引擎,適用于 Web 和獨立環(huán)境。Thymeleaf 的主要目標是為您的開發(fā)工作流程帶來優(yōu)雅的自然模板,本文就來用它實現一個前端表格,感興趣的可以了解一下2022-10-10