為什么把settings.xml復制一份到本地倉庫路徑下,下次重新安裝maven就不用再修改settings.xml?
為什么把settings.xml復制一份到本地倉庫路徑下,下次重新安裝maven就不用再修改settings.xml呢?
1)那么原來../conf下的那份settings.xml可以刪掉嗎?
2)maven/系統怎么知道settings.xml被復制到本地倉庫路徑下了?
。。。。。不要告訴我這樣做只是把settings.xml做一個備份,僅此而已-_-||||
為什么把settings.xml復制一份到本地倉庫路徑下,下次重新安裝maven就不用再修改settings.xml呢?
1)那么原來../conf下的那份settings.xml可以刪掉嗎?
2)maven/系統怎么知道settings.xml被復制到本地倉庫路徑下了?
。。。。。不要告訴我這樣做只是把settings.xml做一個備份,僅此而已-_-||||
2016-01-05
舉報
2016-01-05
這個貌似不行吧!因為你在環境變量做了一個這樣的配置:
感覺只能用指定的了,在conf/settings.xml中配置本地倉庫路徑進行了!個人理解,僅供參考!
又在settings文件看到了這樣兩句話!
<!-- ?|?This?is?the?configuration?file?for?Maven.?It?can?be?specified?at?two?levels: ?| ?|??1.?User?Level.?This?settings.xml?file?provides?configuration?for?a?single?user, ?|?????????????????and?is?normally?provided?in?${user.home}/.m2/settings.xml. ?| ?|?????????????????NOTE:?This?location?can?be?overridden?with?the?CLI?option: ?| ?|?????????????????-s?/path/to/user/settings.xml ?| ?|??2.?Global?Level.?This?settings.xml?file?provides?configuration?for?all?Maven ?|?????????????????users?on?a?machine?(assuming?they're?all?using?the?same?Maven ?|?????????????????installation).?It's?normally?provided?in ?|?????????????????${maven.home}/conf/settings.xml. ?| ?|?????????????????NOTE:?This?location?can?be?overridden?with?the?CLI?option: ?| ?|?????????????????-gs?/path/to/global/settings.xml ?| ?|?The?sections?in?this?sample?file?are?intended?to?give?you?a?running?start?at ?|?getting?the?most?out?of?your?Maven?installation.?Where?appropriate,?the?default ?|?values?(values?used?when?the?setting?is?not?specified)?are?provided. ?| ?|-->你可以在命令行中手動去修改settings.xml所在的位置:這樣就和使用IDE一樣了,即通過修改settings.xml位置,通過settings.xml中的localRepository去找本地倉庫,
可以這樣做:先輸入mvn -h
會在下面的幫助中看到這樣的命令:
如何修改:我自己試了,沒有成功!
但是默認路徑是${user.home}/.m2/settings.xml,那你把settings.xml復制到那個路徑下,也能實現你要的效果了!
2016-01-05
maven是不知道的,所以還是要你把舊的settings復制過去,就好像你在配置文件里更改了本地倉庫地址,maven就會重新下載所有所需的支持jar,而不會用之前路徑下的jar一樣。
2016-01-05
@小小小小小小童鞋
?? ? ? ?先謝謝。你這個從eclipse的角度來講解,也就是說eclipse會根據你配置的settings.xml路徑來自動找到你的本地倉庫地址。那么下次重新安裝maven時,盡管舊的maven根目錄下所有東西都卸載/刪除了。但是在eclipse配置的這個settings.xml路徑還在(因為這個settings.xml不是maven根目錄下,不會因為刪除舊版本而被刪除),所以eclipse還會找到你原本的本地倉庫。好,這些我都理解了。?
? ? ? ? 但是.....你的回答是建立在eclipse,建立在eclipse知道maven的settings.xml在哪(因為我們手動告訴了eclipse的User Settings嘛-_-|||)。那如果不在eclipse集成環境中使用maven呢?像一開始老師講解的章節,不用IDE,那么新裝了maven之后,maven怎么知道我們要使用的是舊的settings.xml?而不是新版本自帶的/conf/setting.xml呢?還望能補充,謝謝。
2016-01-05
D:\Eclipse\.m2\settings.xml為本地倉庫下的settings,這樣做的好處確實是重新安裝Maven,就不用再修改maven本地倉庫中的settings.xml文件,為什么呢?這也與Maven的 User Settings 有關,它是根據你的User Settings設置去找與設置同目錄的本地倉庫!你可以看到上圖中,D:/Eclipse/.m2/repository(本地倉庫路徑)是自動根據上面的 User Settings D:\Eclipse\.m2\settings.xml 自動選擇的!你自己試一下安裝就Maven就知道了了!
如果我再次安裝Maven,我只需改變
1)那么原來../conf下的那份settings.xml可以刪掉嗎?
2)maven/系統怎么知道settings.xml被賦值到本地倉庫路徑下了?
第一個問題:還是保留吧,備份一下!
第二個問題:上面已經回答了,是根據setting.xml去找的本地倉庫!自己試一下,就能理解了!