我对比了一些maven的私服以后,感觉nexus最好使,把搭建的过程步骤一下吧,我的环境是cent5, tomcat 6 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地址修改为你自己的服务器地址 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> 这样一来经过我的测试,如果你在没有局域网的环境中(也就是没办法访问你的私服),只要将pom里面的那段删除就可以了。 (这里默认是部署到realease下,我们可以部署到不同的部署仓库,特别是不同的部门之间) 有时候会出现401错误,那是因为默认是使用deployment账号登录,realease它的默认的Deployment Policy是“Disable Redeploy”,所以无法部署的问题在这个地方,该过来: 不过这样就变得谁都可以部署了,所以还需要设置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一致。(这里的密码还可以用其他方法加密) |
|