好久不寫代碼,突然需要寫點小程式,手生,記錄知識點備忘:
表現:匯入項目到工作空間後,編譯時間顯示maven在下載資源,但速度巨慢,無法忍受。
eclipse中修改maven中央倉庫:2種方式
方式1:(已測試)
作用於所有工作空間:
1、逐項開啟:eclipse->preference->Maven->User Settings。按視窗中的User Settings文字框顯示的路徑,建立settings.xml檔案,或修改路徑後建立檔案。
2、關閉視窗後重新開啟,點擊“open file”,在IDE中開啟該設定檔,出現“could not read settings.xml”不必管。
3、複製下列內容至設定檔,其中<mirror></mirror>部分為國內鏡像。
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><mirrors><!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | --> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>uk</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror> <mirror> <id>CN</id> <name>OSChina Central</name> <url>http://maven.oschina.net/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>nexus</id> <name>internal nexus repository</name> <url>http://repo.maven.apache.org/maven2</url> <mirrorOf>central</mirrorOf> </mirror></mirrors><profiles><profile><id>default</id><repositories><repository><id>nexus</id><name>local private nexus</name><url>http://maven.oschina.net/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>nexus</id><name>local private nexus</name><url>http://maven.oschina.net/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles></settings>
4、"apply"後配置生效,重新編譯即可。