基本命令
mvn install:install-file -Dfile=/Users/mac/Downloads/jave-1.0.2/jave-1.0.2.jar -DgroupId=it.sauronsoftware -DartifactId=jave -Dversion=1.0.2 -Dpackaging=jar
注意:如果没有配置全局环境变量,请找到你maven文件夹,在文件夹的bin目录中进行命令。
-Dfile -> jar包的路径
-DgroupId -> 对应maven依赖中的groupId
-Dversion -> 对应maven依赖中的Dversion,版本号
-DartifactId -> 对应maven依赖中的DartifactId
常见错误
image.png
maven目录里的setting.xml文件中<localRepository>节点的地址和你本地仓库地址不匹配
<!--
<localRepository>/java/maven/apache-maven-3.6.3/properties</localRepository>
-->
<!-- 一般idea使用的本地仓库地址 -->
<localRepository>/Users/mac/.m2/repository</localRepository>
如果仓库地址没有错误,请检查setting.xml文件中是否有多余的节点信息,比如多了一个<mirrors>
image.png
上传成功
image.png
在pom.xml文件中按照格式添加依赖就可以了
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
</dependency>