maven私服上传jar文件

来源:互联网 发布:rsc数据库 编辑:程序博客网 时间:2024/04/20 18:50
  1. 我们知道,每个公司都会有自己的工具包或公共包,这种包就可以上传到公司的maven私服,就不用每个人都去同步开发包了。那么,怎么把本地项目打包并发布到私服呢?按照如下步骤就可以轻松完成。  

1.  在setting.xml文件中增加如下内容:

[html] view plain copy
  1. <servers>  
  2.    <server>  
  3.      <!-- 发布的位置在POM中配置,以ID为关联,有很多公用的信息需要配置在POM文件里,最佳实践是定义一个公司级别的root pom -->  
  4.      <id>nexus</id>  
  5.      <username>admin</username>  
  6.      <password>admin123</password>  
  7.    </server>  
  8.    <server>  
  9.      <id>nexus-snapshots</id>  
  10.      <username>admin</username>  
  11.      <password>admin123</password>  
  12.    </server>  
  13. <server>  
  14.      <id>thirdparty</id>  
  15.      <username>admin</username>  
  16.      <password>admin123</password>  
  17.    </server>  
  18.  </servers>  


2. 在项目的pom.xml文件中增加如下内容

[html] view plain copy
  1.  <distributionManagement>  
  2. <repository>  
  3.     <id>nexus</id>  
  4.     <name>local private nexus</name>  
  5.     <url>http://192.168.xx.xx:8081/nexus/content/groups/public</url>  
  6. </repository>  
  7. <snapshotRepository>  
  8.     <id>nexus-snapshots</id>  
  9.     <name>local private nexus snapshots</name>  
  10.     <url>http://192.168.xx.xx:8081/nexus/content/groups/public-snapshots</url>  
  11. </snapshotRepository>  
  12.  </distributionManagement>   
[html] view plain copy
  1. <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> </span>  

3.  在项目的 maven bulider中的Goals输入如下内容

deploy:deploy-file -DgroupId=com.ivifi.tools -DartifactId=ivifi.tools -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=D:\git\tools\visn.tools\target\ivifi.tools-1.0-SNAPSHOT.jar  -Durl=http://192.168.xx.xx:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

0 0