mvn install:installfile将本地一个中央仓库没有的jar包,推到本地仓库所有依赖不上仓库不能用!

前提:maven等环境配置Ok

目标:把中央仓库没有的,部门内部 自研开发的jar,推到私服或者本地服务器,给相关项目组使用!

     因为一般工程模块自己mvn install就会推到仓库,但是别人给你个jar包咋整?有源码 一般mvn install就会上本地仓库,没有源码只有jar包

1.在需要推的jar的位置,执行以下命令(注意空格和中杠) :mvn install:install-file -Dfile=E:\test\daofree.jar -DgroupId=com.njjn -DartifactId=daofree -Dversion=1.0 -Dpackaging=jar

2.BUILD SUCCESS后去仓库查看,已经生成了目标文件。可以发现仓库里的jar包名称也已经按照命令参数发生了变化。

--安装第三方jar包到本地仓库

----进入jar包所在目录运行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dfile=fastjson-1.1.37.jar -Dpackaging=jar
----打开cmd直接运行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=E:\test\安装第三方jar包\fastjson-1.1.37.jar

--安装第三方jar包到私服nexus

--在settings配置文件中添加登录私服第三方登录信息
<server>
  <id>thirdparty</id>
  <username>admin</username>
  <password>admin123</password>
</server>


----进入jar包所在目录运行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty


----打开cmd直接运行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=E:\test\fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

原文地址:https://www.cnblogs.com/daofree/p/12681855.html