maven 配置私服 连接

两种方法:

1.在单个项目的pom.xml中使用 私服的连接地址,这样只对该项目起作用。

2.在maven的setting.xml配置中添加私服的连接地址。这样对所有项目起作用。

本文章只演示第二种方法:

1.确保nexus私服安装完成并启动。

2.修改本机maven/conf/setting.xml下的配置文件。

完整如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  6. //maven的仓库位置
  7. <localRepository>D:MAVEN_repository</localRepository>
  8.  
  9. <pluginGroups> </pluginGroups>
  10.  
  11. <proxies> </proxies>
  12. //maven操作nexus的权限设置
  13. </servers>
  14. <server>
  15. <id>nexus-releases</id>
  16. <username>admin</username>
  17. <password>admin123</password>
  18. </server>
  19. <server>
  20. <id>nexus-snapshots</id>
  21. <username>admin</username>
  22. <password>admin123</password>
  23. </server>
  24. <server>
  25. <id>3rd-proty</id>
  26. <username>admin</username>
  27. <password>admin123</password>
  28. </server>
  29. </servers>
  30. //配置镜像,让maven只使用私服获取
  31. <mirrors>
  32. <mirror>
  33. <id>nexus</id>
  34. <name>Nexus Repository</name>
  35. <url>http://10.0.27.61:8081/content/groups/public</url>
  36. <mirrorOf>*</mirrorOf>
  37. </mirror>
  38. </mirrors>
  39. //配置仓库车插件,一旦配置了镜像,则 这个配置可忽略
  40. <profiles>
  41. <profile>
  42. <id>nexus</id>
  43. <repositories>
  44. <repository>
  45. <id>nexus</id>
  46. <url>http://10.0.27.61:8081/content/groups/public</url>
  47. <releases>
  48. <enabled>true</enabled>
  49. </releases>
  50. <snapshots>
  51. <enabled>true</enabled>
  52. </snapshots>
  53. </repository>
  54. </repositories>
  55. <pluginRepositories>
  56. <pluginRepository>
  57. <id>nexus</id>
  58. <url>http://10.0.27.61:8081/content/groups/public</url>
  59. <releases>
  60. <enabled>true</enabled>
  61. </releases>
  62. <snapshots>
  63. <enabled>true</enabled>
  64. </snapshots>
  65. </pluginRepository>
  66. </pluginRepositories>
  67. </profile>
  68. </profiles>
  69. //激活上面的配置
  70. <activeProfiles>
  71. <activeProfile>nexus</activeProfile>
  72. </activeProfiles>
  73.  
  74. </settings>
原文地址:https://www.cnblogs.com/zhuyeshen/p/11428896.html