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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM