我對比了一些maven的私服以后,感覺(jué)nexus最好使,把搭建的過(guò)程步驟一下吧,我的環(huán)境是cent5, tomcat 6
1、下載war包,部署到tomcat中,啟動(dòng)tomcat;
2、訪(fǎng)問(wèn):http://xxx/nexus-1.1.1/index.html;
3、用admin/admin123登錄;
4、修改admin的密碼,但是不要修改別的屬性和修改別的用戶(hù)信息
5、進(jìn)入administration中的repositories,依次修改三個(gè)type是proxy的項目,將其Download Remote Indexes修改為true;然后郵件他們,分別re-index一下;(Nexus中有三個(gè)重要的代理倉庫,分別是中央倉庫,Apache倉庫,Codehau倉庫,他們的每一個(gè)倉庫都包含了數千或者數萬(wàn)的構件,不可能下載所有構件,而是保存了一個(gè)索引,以提供快速和有效的搜索。)
6、將你自己機器上的manven緩存(一般是在C:\Documents and Settings\登錄名\.m2下面)全部拷貝到/home/你的用戶(hù)名/sonatype-work/nexus/storage下面的central和releases各一份;
7、修改你本地的(一般是在C:\Documents and Settings\登錄名\.m2下面)setting.xml文件改成下面的:
Xml代碼

1. <settings>
2. <proxies>
3. <proxy>
4. <id>normal</id>
5. <active>true</active>
6. <protocol>http</protocol>
7. <username>deployment</username>
8. <password>deploy</password>
9. <host>172.19.0.177:8080/nexus-1.1.1</host>
10. <port>80</port>
11. <nonProxyHosts>172.19.0.177:8080/nexus-1.1.1</nonProxyHosts>
12. </proxy>
13. </proxies>
14. <servers>
15. </servers>
16. <mirrors>
17. <mirror>
18. <id>nexus-public-snapshots</id>
19. <mirrorOf>public-snapshots</mirrorOf>
20. <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public-snapshots</url>
21. </mirror>
22. <mirror>
23. <!--This sends everything else to /public -->
24. <id>nexus</id>
25. <mirrorOf>*</mirrorOf>
26. <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public</url>
27. </mirror>
28. </mirrors>
29. <profiles>
30. <profile>
31. <id>development</id>
32. <repositories>
33. <repository>
34. <id>central</id>
35. <url>http://central</url>
36. <releases><enabled>true</enabled></releases>
37. <snapshots><enabled>true</enabled></snapshots>
38. </repository>
39. </repositories>
40. <pluginRepositories>
41. <pluginRepository>
42. <id>central</id>
43. <url>http://central</url>
44. <releases><enabled>true</enabled></releases>
45. <snapshots><enabled>true</enabled></snapshots>
46. </pluginRepository>
47. </pluginRepositories>
48. </profile>
49. <profile>
50. <id>public-snapshots</id>
51. <repositories>
52. <repository>
53. <id>public-snapshots</id>
54. <url>http://public-snapshots</url>
55. <releases><enabled>false</enabled></releases>
56. <snapshots><enabled>true</enabled></snapshots>
57. </repository>
58. </repositories>
59. <pluginRepositories>
60. <pluginRepository>
61. <id>public-snapshots</id>
62. <url>http://public-snapshots</url>
63. <releases><enabled>false</enabled></releases>
64. <snapshots><enabled>true</enabled></snapshots>
65. </pluginRepository>
66. </pluginRepositories>
67. </profile>
68. </profiles>
69. <activeProfiles>
70. <activeProfile>development</activeProfile>
71. </activeProfiles>
72. </settings>
將172.19.0.177地址修改為你自己的服務(wù)器地址
8、在你的項目中的pom.xml中增加一段:
Xml代碼

1. <distributionManagement>
2. <repository>
3. <id>repo</id>
4. <name>public</name>
5. <url>http://172.19.0.177:8080/nexus-1.1.1/content/repositories/releases</url>
6. </repository>
7. <snapshotRepository>
8. <id>Snapshots</id>
9. <name>Snapshots</name>
10. <url>http://172.19.0.177:8080/nexus-1.1.1/content/repositories/snapshots</url>
11. </snapshotRepository>
12. </distributionManagement>
(這里默認是部署到realease下,我們可以部署到不同的部署倉庫,特別是不同的部門(mén)之間)
有時(shí)候會(huì )出現401錯誤,那是因為默認是使用deployment賬號登錄,realease它的默認的Deployment Policy是“Disable Redeploy”,所以無(wú)法部署的問(wèn)題在這個(gè)地方,該過(guò)來(lái):

不過(guò)這樣就變得誰(shuí)都可以部署了,所以還需要設置deployment的密碼:

然后再setting中加上密碼:
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>deploydv89</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>deploydv89</password>
</server>
注意,pom中的id要和這里的id一致。(這里的密碼還可以用其他方法加密)
聯(lián)系客服