Maven從Nexus獲取構建以及上傳構建方法

配置maven從Nexus獲取構建

  1. 配置本地倉庫地址如果不配置默認在user/.m2/路徑下存儲
    我不喜歡存儲在c盤,所以設置在d盤
    localRepository>D:/softdata/maven-repo</localRepository>

  2. 在setings.xml配置mirror就可以從nexus遠程倉庫獲取構建

 <mirror>
     <id>nexus</id>
     <name>group</name>
     <url>http://localhost:8081/repository/maven-group/</url>
     <mirrorOf>*</mirrorOf> //配置所有構建獲取都通過nexus私服
 </mirror>
  1. 在settings.xml配置maven可以從倉庫和插件倉庫獲取快照版本和發佈版本
<profile>
  <id>nexus</id>
  <repositories>
    <id>nexus</id>
    <name>Nexus</name>
    <url>http://localhost:8081/repository/maven-group/</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
	  <id>nexus</id>
	  <name>Nexues</name>
	  <url>http://localhost:8081/repository/maven-group/</url>
	  <snapshots><enabled>true</enabled></snapshots>
	  <releases><enabled>true</enabled></releases>
    </pluginRepository>
  </pluginRepositories>
</profile>
 <activeProfiles>
   <activeProfile>nexus</activeProfile>
 </activeProfiles>
  1. 配置nexus服務驗證,如果不配置有可能請求被拒絕
	<server>
      <id>nexus-snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>nexus-release</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

配置maven從Nexus上傳構建

  1. 項目中配置發佈管理,最好在聚合模塊中配置,配置發佈快照版本庫以及發佈版本庫
<distributionManagement>
 	<snapshotRepository>
 		<id>nexus-snapshots</id>
 		<name>Nexus SnapShots Repository</name>
 		<url>http://localhost:8081/repository/maven-snapshots/</url>
 	</snapshotRepository>
 	<repository>
 		<id>nexus-release</id>
 		<name>Nexus Release Repository</name>
 		<url>http://localhost:8081/repository/maven-releases/</url>
 	</repository>
 </distributionManagement>
  1. 執行maven clean deploy就可以在nexus中看到了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章