maven配置私服,发布到私服 偏执的太偏执、 2021-09-10 20:52 391阅读 0赞 1)、 配置Maven 从私服上下载构件 a、在POM.xml文件中配置 **\[html\]** [view plain][] [copy][view plain] 1. **<****repositories****>** 2. **<****repository****>** 3. **<****id****>**central.maven.com**</****id****>** 4. **<****name****>**mapbar central mirror.**</****name****>** 5. **<****url****>**http://192.168.1.252:8081/nexus/content/repositories/central/**</****url****>** 6. **</****repository****>** 7. **<****repository****>** 8. **<****id****>**3rd.mapbar.com**</****id****>** 9. **<****name****>**mapbar thirdparty central mirror.**</****name****>** 10. **<****url****>**http://192.168.1.252:8081/nexus/content/repositories/thirdparty/**</****url****>** 11. **</****repository****>** 12. **<****repository****>** 13. **<****id****>**public.mapbar.com**</****id****>** 14. **<****name****>**mapbar tech API maven mirror.**</****name****>** 15. **<****url****>**http://192.168.1.252:8081/nexus/content/groups/public/**</****url****>** 16. **</****repository****>** 17. **<****repository****>** 18. **<****id****>**releases.mapbar.com**</****id****>** 19. **<****name****>**mapbar thirdparty central mirror.**</****name****>** 20. **<****url****>**http://192.168.1.252:8081/nexus/content/repositories/releases/**</****url****>** 21. **</****repository****>** 22. **</****repositories****>** 这样的配置只对Maven项目有效,在实际引用中,我们想通过一次配置就能让本机所有的Maven项目都能使用自己的Maven私服。这个时候就要用settings.xml 文件。改文件对本机所有的Maven项目有效。配置如下: **\[html\]** [view plain][] [copy][view plain] 1. **<****profiles****>** 2. **<****profile****>** 3. **<****id****>**nexus**</****id****>** 4. **<****repositories****>** 5. **<****repository****>** 6. **<****id****>**nexus**</****id****>** 7. **<****name****>**Nexus**</****name****>** 8. **<****url****>**http://192.168.53.55:8081/nexus/content/groups/public/**</****url****>** 9. **<****releases****>** 10. **<****enabled****>**true**</****enabled****>** 11. **</****releases****>** 12. **<****snapshots****>** 13. **<****enabled****>**true**</****enabled****>** 14. **</****snapshots****>** 15. **</****repository****>** 16. **</****repositories****>** 17. **<****pluginRepositories****>** 18. **<****pluginRepository****>** 19. **<****id****>**nexus**</****id****>** 20. **<****name****>**Nexus**</****name****>** 21. **<****url****>**http://192.168.53.55:8081/nexus/content/groups/public/**</****url****>** 22. **<****releases****>** 23. **<****enabled****>**true**</****enabled****>** 24. **</****releases****>** 25. **<****snapshots****>** 26. **<****enabled****>**true**</****enabled****>** 27. **</****snapshots****>** 28. **</****pluginRepository****>** 29. **</****pluginRepositories****>** 30. **</****profile****>** 31. **</****profiles****>** 32. **<****activeProfiles****>** 33. **<****activeProfile****>**nexus**</****activeProfile****>** 34. **</****activeProfiles****>** 2)、配置自动发布构件到私服 POM.XML 配置: **\[html\]** [view plain][] [copy][view plain] 1. **<****distributionManagement****>** 2. **<****repository****>** 3. **<****id****>**releases**</****id****>** 4. **<****url****>**http://localhost:8081/nexus/content/repositories/thirdparty/**</****url****>** 5. **</****repository****>** 6. **</****distributionManagement****>** 在命令行键入:mavn deploy 则构件自动发布到本地和上传到私服 [http://localhost:8081/nexus/content/repositories/thirdparty][http_localhost_8081_nexus_content_repositories_thirdparty] 这个目录下 需要注意2点: 1、发布的版本类型必须和nexus里的Policy类型一致。 2、setting.xml 文件必须配置servers,其中id必须和repository下的id一致。 **\[html\]** [view plain][] [copy][view plain] 1. **<****servers****>** 2. **<****server****>** 3. **<****id****>**releases**</****id****>** 4. **<****username****>**admin**</****username****>** 5. **<****password****>**admin123**</****password****>** 6. **</****server****>** 7. **<****server****>** 8. **<****id****>**snapshots**</****id****>** 9. **<****username****>**admin**</****username****>** 10. **<****password****>**admin123**</****password****>** 11. **</****server****>** 12. **<****server****>** 13. **<****id****>**deploymentRepo**</****id****>** 14. **<****username****>**admin**</****username****>** 15. **<****password****>**admin123**</****password****>** 16. **</****server****>** 17. **</****servers****>** 3)、在<build> 中配置项目构建信息,生成doc,source **\[html\]** [view plain][] [copy][view plain] 1. <!-- 项目的构建信息 --> 2. **<****build****>** 3. **<****plugins****>** 4. <!-- generate a javasource --> 5. **<****plugin****>** 6. **<****groupId****>**org.apache.maven.plugins**</****groupId****>** 7. **<****artifactId****>**maven-source-plugin**</****artifactId****>** 8. **<****executions****>** 9. **<****execution****>** 10. **<****id****>**attach-sources**</****id****>** 11. **<****goals****>** 12. **<****goal****>**jar**</****goal****>** 13. **</****goals****>** 14. **</****execution****>** 15. **</****executions****>** 16. **</****plugin****>** 17. <!-- generate a javadoc --> 18. **<****plugin****>** 19. **<****groupId****>**org.apache.maven.plugins**</****groupId****>** 20. **<****artifactId****>**maven-javadoc-plugin**</****artifactId****>** 21. **<****executions****>** 22. **<****execution****>** 23. **<****id****>**attach-javadocs**</****id****>** 24. **<****goals****>** 25. **<****goal****>**jar**</****goal****>** 26. **</****goals****>** 27. **</****execution****>** 28. **</****executions****>** 29. **</****plugin****>** 30. **</****plugins****>** 31. **</****build****>** 输入命令:mvn install 在target目录下生成了 MavenTest-0.0.1-release.jar --.class文件 MavenTest-0.0.1-release-sources.jar --.java 文件 MavenTest-0.0.1-release-javadoc.jar --doc 文件 [view plain]: http://blog.csdn.net/cdl2008sky/article/details/6753759# [http_localhost_8081_nexus_content_repositories_thirdparty]: http://localhost:8081/nexus/content/repositories/thirdparty
还没有评论,来说两句吧...