cmd输入命令 最好进入到jar包的绝对路径 git
mvn deploy:deploy-file -DgroupId=zhongjin -DartifactId=API4BDS -Dversion=2.3 -Dpackaging=jar -Dfile=G:\p2p\API4BDS-2.3.jar -Durl=http://192.168.34.35:81/nexus/content/repositories/releases -DrepositoryId=releases 缓存
DgroupId和DartifactId构成了该jar包在pom.xml的坐标,项目就是依靠这两个属性定位。本身起名字也行。 服务器
Dfile表示须要上传的jar包的绝对路径maven
Durl私服上仓库的位置,打开nexus——>repositories菜单,能够看到该路径url
DrepositoryId服务器的表示id,在nexus的configuration能够看到spa
Dversion表示版本信息,怎样获得一个jar包准确的版本呢? 解压该包,会发现一个叫MANIFEST.MF的文件,这个文件就有描述该包的版本信息。 好比Manifest-Version: 1.0能够知道该包的版本了.net
上传成功后,在nexus界面点击3rd party仓库能够看到这包。3d
详情见:https://blog.csdn.net/u013308504/article/details/78952221代理
使用Sonatype Nexus搭建Maven私服后添加第三方JAR包
登陆Nexus后,点击右侧的“Repositories”,显示当前Nexus所管理的Repository,xml
默认状况下Nexus为咱们建立了如下主要的Repository:
(1)PublicRepositories,这是一个Repository Group,该Repository Group包含了多个Repository,其中包含了Releases、Snapshots、ThirdParty和Central。
(2)3rd party,该Repository便是存放你公司所购买的第三方软件库的地方,它是一个由Nexus本身维护的一个Repository。
(3)Apache Snapshots,看名字你就应该知道这是个什么样的Repository,这是一个代理Repository,即最终的依赖仍是得在Apache官网上去下载,而后缓存在Nexus中。
(4)Central,这就是代理Maven Central Repository的Repository。
(5)Releases,你本身的项目要发布时,就应该发布在这个Repository,他也是Nexus本身维护的Repository,而不是代理。
(6)Snapshots,你本身项目Snapshot的Repository。
这里主要讲解如何使用3rd party上传第三方jar包的方法
在Repository列表中,选中 3rd party,选中artifact upload,以下图所示
选择GAV Defini3ion: GAV Parameters,Auto Guess 打钩。
在下方输入JAR包对应的Group、Artifact、Version,Packaging选择JAR格式。
点击select Artifact(s) to upload 按钮,选择要上传的JAR包。
怎么使用上传的jar包吧,很简单的,前提是你已经创建了一个maven的项目。含有pom.xml这个文件,在这个文件中添加以下:
详情见:https://blog.csdn.net/xiaomageit/article/details/51492056?locationNum=2&fps=1