向nexus3私服上传jar包

向nexus3私服上传jar包

一般向私服上传jar包有三种方法:

  • 直接浏览器
  • cmd模式
  • IDE集成环境

准备环境

1.创建3rd_part

使用默认用户admin/admin123登陆

向nexus3私服上传jar包_第1张图片

点击左侧的repository\repositories后,在右侧点击create repository

向nexus3私服上传jar包_第2张图片

然后选择maven2(hosted),填写如下

向nexus3私服上传jar包_第3张图片

跳到首页后选择maven-public

向nexus3私服上传jar包_第4张图片

3rd_part移到member中,即将33rd_partmaven-public管理,点击save

向nexus3私服上传jar包_第5张图片

至此,创建仓库完成

2.创建3rd_part管理用户

创建用户: 用户名/密码-dev/dev123

向nexus3私服上传jar包_第6张图片

直接浏览器

使用dev/dev123登陆,点击upload

向nexus3私服上传jar包_第7张图片

填写上传jar包的信息后,点击upload

向nexus3私服上传jar包_第8张图片

可以看到已经上传成功

向nexus3私服上传jar包_第9张图片

cmd模式

1.复制一份settings.xmlsettings-private.xml,在settings-private.xml文件中加入节点server:

<server>
  <id>deploymentid>
  <username>devusername>
  <password>dev123password>
server>

在命令行中输入

mvn deploy:deploy-file
-DgroupId=com.sjing.yjyuan
-DartifactId=fastjson-sj
-Dversion=1.0.1
-Dpackaging=jar
-Dfile=E:\installed\mavenRepository\fastjson-1.2.40.jar
-Durl=http://192.168.1*9.1*0:8081/repository/3rd_part/
-DrepositoryId=deployment
--settings E:\installed\mavenRepository\settings-private.xml

其中-Durl3rd_part仓库的地址

向nexus3私服上传jar包_第10张图片

-DrepositoryId即为之前server节点中的属性id的值,--settings指定maven的setting文件,即

向nexus3私服上传jar包_第11张图片

IDE集成环境

settings-private.xml中的servers节点加入

<server>
  <id>nexus-releaseid>
  <username>devusername>
  <password>dev123password>
server>
<server>
  <id>nexus-snapshotsid>
  <username>devusername>
  <password>dev123password>
server>

在maven工程项目nexus-upload中的pom文件中加入


<distributionManagement>
 <repository>
     
     <id>nexus-releaseid>
     <name>Nexus release Repositoryname>
     
     <url>http://192.168.1*9.1*0:8081/repository/maven-releases/url>
 repository>
 <snapshotRepository>
     <id>nexus-snapshotsid>
     <name>Nexus snapshots Repositoryname>
     
     <url>http://192.168.1*9.1*0:8081/repository/maven-snapshots/url>
 snapshotRepository>
distributionManagement>

然后运行mvn deploy

可以在控制台

[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ nexus-upload ---
Downloading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/nexus-upload-1.0-20180303.072618-1.jar
Uploaded: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/nexus-upload-1.0-20180303.072618-1.jar (3 KB at 4.6 KB/sec)
Uploading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/nexus-upload-1.0-20180303.072618-1.pom
Uploaded: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/nexus-upload-1.0-20180303.072618-1.pom (4 KB at 9.6 KB/sec)
Downloading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/maven-metadata.xml
Uploading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/1.0-SNAPSHOT/maven-metadata.xml (773 B at 2.7 KB/sec)
Uploading: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/maven-metadata.xml
Uploaded: http://192.168.1*9.1*0:8081/repository/maven-snapshots/com/sijing/yjyuan/nexus-upload/maven-metadata.xml (287 B at 1.5 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.368 s
[INFO] Finished at: 2018-03-03T15:26:20+08:00
[INFO] Final Memory: 15M/250M
[INFO] ------------------------------------------------------------------------

在nexus私服中可以看到

向nexus3私服上传jar包_第12张图片

你可能感兴趣的:(maven)