解決idea找不到setting.xml文件的問題
對于找不到maven倉庫的setting.xml文件
網(wǎng)上各種說法
但是我在idea里面找到了一個思路介紹給大家補(bǔ)充:Maven Settings.xml文件及常見問題總結(jié)
Settings.xml 文件<localRepository>
配置本地倉庫地址,如:
<localRepository>D:.m2repository</localRepository>
<servers>
配置私服地址。如果為公共服務(wù)器,不需要賬號,密碼,則可不配置。只要配置<mirror>標(biāo)簽即可(<mirror>見1.3小節(jié))如:
<server> <id>nexus</id> <username>yanfa</username> <password>yanfa</password></server>
<mirror>
mirror則相當(dāng)于一個代理,它會攔截去指定的遠(yuǎn)程repository下載構(gòu)件的請求,然后從自己這里找出構(gòu)件回送給客戶端。配置mirror的目的一般是出于網(wǎng)速考慮。
如果配置為*,如下面配置文件所示,則如果這個mirror掛掉,maven將無法訪問任何遠(yuǎn)程倉庫,因而將無法下載構(gòu)件。
配置遠(yuǎn)程倉庫地址:
<mirror> <id>nexus</id> <name>Nexus</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <mirrorOf>*</mirrorOf> </mirror>
<repository>
internal repository是指在局域網(wǎng)內(nèi)部搭建的repository,它跟central repository, jboss repository等的區(qū)別僅僅在于其URL是一個內(nèi)部網(wǎng)址。
配置遠(yuǎn)程倉庫信息:
<repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>
<pluginRepository>
配置插件信息,如tomcat等插件:
<pluginRepository> <id>nexus</id> <name>Nexus Repository</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository>常見問題
Q: Maven 本地倉庫明明有jar包,pom文件還是報錯解決?
A: 解決方法:找到出錯的jar包文件在本地倉庫的位置,刪掉_maven.repositories文件。
原因:更換settings.xml 配置文件后,如果配置的respositoryId中不包含這個私服的repositoryId,maven本不會讓這個本地的jar包,maven就會自動到配置的庫中找到,找不到就會報錯。
Q: 明明已經(jīng)設(shè)置本地倉庫,但maven每次更新時,還是要到網(wǎng)上下載?
A: 本地沒有下載到真正的 jar 包(而是帶有l(wèi)ast-updated后綴的文件),只能再到網(wǎng)上下載。
Q: Maven 應(yīng)用jar 版本不對,如何解決?
A: 1. 首先查看本地倉庫中的目標(biāo)jar包版本是否存在。2. 如果存在,查看.pom 文件,知道其坐標(biāo), 然后在需要引用的工程的pom.xml文件中添加dependency 引用。 3. 如果不存在, 看私服中是否有改目標(biāo)版本的文件,有,就下載即可。
優(yōu)勢未使用maven管理,每一個項目都要帶一些jar包,增大了項目的體積,需要更多的時間部署;同時每個項目之間肯定有一些公用的jar包,如果能夠集中式管理jar,這樣會節(jié)省很多的空間。
以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。如有錯誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章:
1. python 如何在 Matplotlib 中繪制垂直線2. bootstrap select2 動態(tài)從后臺Ajax動態(tài)獲取數(shù)據(jù)的代碼3. ASP常用日期格式化函數(shù) FormatDate()4. python中@contextmanager實(shí)例用法5. html中的form不提交(排除)某些input 原創(chuàng)6. CSS3中Transition屬性詳解以及示例分享7. js select支持手動輸入功能實(shí)現(xiàn)代碼8. 如何通過python實(shí)現(xiàn)IOU計算代碼實(shí)例9. 開發(fā)效率翻倍的Web API使用技巧10. vue使用moment如何將時間戳轉(zhuǎn)為標(biāo)準(zhǔn)日期時間格式
