命令格式:

mvn install:install-file -Dfile=jar包全名称(参数一) -DgroupId=groupId(参数二) 
-DartifactId=artifactId(参数三) -Dversion=version(参数四) -Dpackaging=jar

说明:创建的maven仓库包路径:groupId(参数二)/artifactId(参数三)​/​version(参数四)​/​jar包全名称​-version​


例一:

mvn install:install-file -Dfile=fmpp-0.9.16.jar -DgroupId=net.sourceforge.fmpp -DartifactId=fmpp -Dversion=0.9.16 -Dpackaging=jar

手动安装jar文件到本地maven仓库中_bc

最终创建的jar路径: maven_3.6.3_idea\repository\ ​​net\sourceforge\fmpp\fmpp\0.9.16\fmpp-0.9.16.jar​​(同时会生成对应的pom文件)。


例二:将桌面下的ojdbc6.jar安装到maven仓库

(1)cd到jar所在目录。

(2)执行下面命令:

mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar

详细过程如下图:

手动安装jar文件到本地maven仓库中_jar_02

最终创建的jar路径: maven_3.6.3_idea\repository\ ​​com\oracle\ojdbc6\11.2.0.3\ojdbc6-11.2.0.3.jar​​(同时会生成对应的pom文件)。