Maven专题(六)-把第三方jar包放入本地仓库或私服

1. 导入本地库

随便找一个 jar 包测试,可以先 CMD进入到 jar 包所在位置,运行

mvn install:install-file -Dfile=D:\8888\fastdfs_client-1.25.jar -DgroupId=fastdfs_client -DartifactId=fastdfs_client -Dversion=1.25 -Dpackaging=jar

在这里插入图片描述
在这里插入图片描述

2. 导入私服

需要在 maven 软件的核心配置文件 settings.xml 中配置第三方仓库的 server 信息

<server>
	<id>thirdparty</id>
	<username>admin</username>
	<password>admin123</password>
</server>

才能执行一下命令

mvn deploy:deploy-file -DgroupId=fastdfs_client -DartifactId=fastdfs_client -Dversion=1.25 -Dpackaging=jar -Dfile=D:\8888\fastdfs_client-1.25.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

在这里插入图片描述
在这里插入图片描述

3. 参数说明

DgroupId 和 DartifactId 构成了该 jar 包在 pom.xml 的坐标,项目就是依靠这两个属性定位。
自己起名字也行。
Dfile 表示需要上传的 jar 包的绝对路径。
Durl 私服上仓库的位置,打开 nexus——>repositories 菜单,可以看到该路径。
DrepositoryId 服务器的表示 id,在 nexus 的 configuration 可以看到。
Dversion 表示版本信息,
关于 jar 包准确的版本:
包的名字上一般会带版本号,如果没有那可以解压该包,会发现一个叫 MANIFEST.MF 的文件,这个文件就有描述该包的版本信息。
比如 Specification-Version: 2.2 可以知道该包的版本了。
上传成功后,在 nexus 界面点击 3rd party 仓库可以看到这包。

发布了274 篇原创文章 · 获赞 80 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/BruceLiu_code/article/details/104131836