天天看點

maven指令上傳包到私服

首先在settings.xml的中添加如下配置

<server>
	<id>thirdparty</id>
	<username>root</username>
	<password>root</password>
</server>
           

例如我需要上傳ojdbc的驅動包到私服去需要執行以下指令

mvn deploy:deploy-file 
-DgroupId=ojdbc14 #groupId
-DartifactId=ojdbc14 #artifactId
-Dversion=10.2.0.3.0 包版本
-Dpackaging=jar #包類型
-Dfile=E:\ojdbc14.jar #需上傳檔案位置
-Durl=http://localhost:8080/nexus/content/repositories/thirdparty/  #倉庫位址 
-DrepositoryId=thirdparty  #此選項與setting中配置的serverid 對應
           

當然你還可以寫成另外的方式指定配置檔案,但是setting中一定要配置伺服器的賬号密碼。

mvn -s "D:maven\settings\settings.xml" deploy:deploy-file 
-DgroupId=ojdbc14 
-DartifactId=ojdbc14 
-Dversion=10.2.0.3.0
-Dpackaging=jar 
-Dfile=E:\ojdbc14.jar 
-Durl=http://localhost:8080/nexus/content/repositories/thirdparty/ 
-DrepositoryId=thirdparty
           

如果你有大量的包需要上傳,例如外包項目,需要把包傳到客戶私服上,可以整理出自己的包放到某個檔案夾下,寫個shell去做這個事情