打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Maven使用nexus配置,SNAPSHOT版本介绍及发布jar到nexus
Maven Setting.xml配置
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">  
  3. <!-- 本地仓库配置 -->  
  4. <localRepository>D:\java\mavenRepos</localRepository>  
  5. <pluginGroups>  
  6. </pluginGroups>  
  7. <proxies>  
  8. </proxies>  
  9. <!-- 服务用户配置 -->  
  10. <servers>  
  11. <server>  
  12. <id>releases</id>  
  13. <username>deployment</username>  
  14. <password>cykj</password>  
  15. </server>  
  16. <server>  
  17. <id>snapshots</id>  
  18. <username>deployment</username>  
  19. <password>cykj</password>  
  20. </server>  
  21. </servers>  
  22. <!-- 镜像配置 -->  
  23. <mirrors>  
  24. <!-- 对snapshots版本有效 -->  
  25. <mirror>  
  26. <id>nexusSnapashots</id>  
  27. <url>http://192.168.2.18:8081/nexus/content/groups/public/</url>  
  28. <mirrorOf>public-snapshots</mirrorOf>  
  29. <interval>always</interval>  
  30. </mirror>  
  31. <mirror>  
  32. <id>nexusMirror</id>  
  33. <name>local repos</name>  
  34. <url>http://192.168.2.18:8081/nexus/content/groups/public/</url>  
  35. <mirrorOf>*</mirrorOf>  
  36. </mirror>  
  37. </mirrors>  
  38. <!-- 条件配置 -->  
  39. <profiles>  
  40. <profile>  
  41. <id>nexusRepository</id>  
  42. <!-- jar包仓库配置 -->  
  43. <repositories>  
  44. <repository>  
  45. <id>nexusSnapashots</id>  
  46. <name>nexus-snapshots</name>  
  47. <url>http://192.168.2.18:8081/nexus/content/groups/public/</url>  
  48. <releases>  
  49. <enabled>false</enabled>  
  50. </releases>  
  51. <snapshots>  
  52. <enabled>true</enabled>  
  53. </snapshots>  
  54. <layout>default</layout>  
  55. <snapshotPolicy>always</snapshotPolicy>  
  56. </repository>  
  57. <repository>  
  58. <id>nexusMirror</id>  
  59. <name>nexus-snapshots</name>  
  60. <url>http://192.168.2.18:8081/nexus/content/groups/public/</url>  
  61. <releases>  
  62. <enabled>true</enabled>  
  63. </releases>  
  64. <snapshots>  
  65. <enabled>false</enabled>  
  66. </snapshots>  
  67. <layout>default</layout>  
  68. <snapshotPolicy>always</snapshotPolicy>  
  69. </repository>  
  70. </repositories>  
  71. <!-- 插件仓库配置 -->  
  72. <pluginRepositories>  
  73. <pluginRepository>  
  74. <id>nexusMirror</id>  
  75. <name>nexus mirror</name>  
  76. <url>http://192.168.2.18:8081/nexus/content/groups/public/</url>  
  77. <releases>  
  78. <enabled>true</enabled>  
  79. </releases>  
  80. <snapshots>  
  81. <enabled>false</enabled>  
  82. <updatePolicy>always</updatePolicy>  
  83. <checksumPolicy>warn</checksumPolicy>    
  84. </snapshots>  
  85. </pluginRepository>  
  86. </pluginRepositories>  
  87. </profile>  
  88. </profiles>  
  89. <!-- 激活profile -->  
  90. <activeProfiles>  
  91. <activeProfile>nexusRepository</activeProfile>  
  92. </activeProfiles>  
  93. </settings>  

关于发布到nexus仓库中,使用mvn deploy命令

eclipse中配置run configuration中加入deploy参数,如图


发布项目到nexus上在pom.xml中加入

  1. <distributionManagement>  
  2.         <repository>  
  3.             <id>releases</id>  
  4.             <name>Nexus Releases Repository</name>  
  5.             <url>http://192.168.2.18:8081/nexus/content/repositories/releases/</url>  
  6.         </repository>  
  7.         <snapshotRepository>  
  8.             <id>snapshots</id>  
  9.             <name>Nexus Snapshots Repository</name>  
  10.             <uniqueVersion>false</uniqueVersion>  
  11.             <layout>legacy</layout>  
  12.             <url>http://192.168.2.18:8081/nexus/content/repositories/snapshots/</url>  
  13.         </snapshotRepository>  
  14.     </distributionManagement>  
注意id与setting中server的id保持一致
server中配置的用户名密码为nexus中的用户id和密码,注意是id不是name,否则报错,当时也是被坑了个first blood出来..

关于SNAPSHOT版本简单介绍一下

如pom.xml中配置<version>1.0.0-SNAPSHOT</version>

表示快照版本,版本虽为1.0.0,但是每次都会使用最新的版本,参考nexus仓库截图,每次提交都会产生不同的版本号


关于发布到nexus仓库中,使用mvn deploy命令

eclipse中配置run configuration中加入deploy参数,如图

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
使用MyEclipse构建MAVEN项目
用nexus搭建自己的maven私有倉庫
关于Maven
我的Maven之旅(5)-建立你自己的本地仓库(Maven仓库管理-Nexus)
Maven2中snapshot快照库的使用 | 铁木箱子
Maven多项目依赖配置
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服