maven國內映象配置(Ubuntu)
阿新 • • 發佈:2019-01-03
maven在apache的官方映象非常慢,嚴重影響速度,建議使用國內的映象。目前國內的映象較少,可以使用oschina的映象,具體配置過程參考:
http://maven.oschina.net/static/help.html
上述安裝過程基於Windows環境,以下過程在Ubuntu 12.04下執行。
maven安裝
Ubuntu下使用apt-get安裝maven即可:$ sudo apt-get install maven
配置maven
修改maven的源:$ sudo vim /etc/maven/settings.xml
修改以下內容。修改<mirrors>
在<mirrors>標籤中增加以下內容:<mirror> <id>nexus-osc</id> <mirrorOf>*</mirrorOf> <name>Nexus osc</name> <url>http://maven.oschina.net/content/groups/public/</url> </mirror>
修改<profiles>
在<profiles>標籤中增加以下內容:<profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <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>
複製配置
將該配置檔案複製到使用者目錄,使得每次對maven建立時,都採用該配置:$ cp /etc/maven/settings.xml ~/.m2/
這樣,通過以上步驟,使用maven編譯其他程式碼時,都是使用的國內映象服務了。