参考网页
mvn install:install-file -DgroupId=com.xxx -DartifactId=searchservice -Dversion=1.1.0.0.0 -Dpackaging=jar -Dfile=…/newJar/searchservice.jar
https://jingyan.baidu.com/article/cbf0e500bba2082eaa289300.html
解析:
mvn install:install-file -DgroupId=
com.xxx
-DartifactId=searchservice
-Dversion=1.1.0.0.0
-Dpackaging=jar -Dfile=../newJar/searchservice.jar
以上特殊字体即为需要改变的地方。
但是我们一般从https://mvnrepository.com/这个网址找到的一般是加到pom.xml里面的代码:
<!-- https://mvnrepository.com/artifact/org.wso2.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.wso2.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1.wso2v1</version>
</dependency>
容易发现的是:
-DgroupId -DartifactId -Dversion这三个参数,很容易理解。
-Dpackaging=jar也可以认为是不需要动的。那么这里,最后一个参数是什么?
-Dfile=../newJar/searchservice.jar
这个参数认为是什么?输出路径?还是Jar包的名称?输出的jar的路径及这个文件。应该是。
案例
这里已经有一位实践过了。
http://blogjava.net/fancydeepin/archive/2012/06/12/380605.html#Post
以下为案例:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Maven 安装 JAR 包的命令是:
mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面的version -Dpackaging=jar
这里说的很清楚了。
例如:
我下载的这个 jar 包是放到了 D:\mvn 目录下(D:\mvn\spring-context-support-3.1.0.RELEASE.jar)
那么我在 cmd 中敲入的命令就应该是:
mvn install:install-file -Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar -DgroupId=org.springframework -DartifactId=spring-context-support -Dversion=3.1.0.RELEASE -Dpackaging=jar
未完待续。
测试命令
执行命令,其中省略了-Dfile即目标地址
代码如下:
mvn install:install-file -DgroupId=org.wso2.apache.httpcomponents -DartifactId=httpclient -Dversion=4.3.1.wso2v1 -Dpackaging=jar
结果图:
下载失败少了一个Jar包。多了一些这些,说明已经执行了命令。(其中,通过按修改日期排序的方法找到这个文件夹的。)
使用IDEA的方法
https://blog.csdn.net/hi_boy_/article/details/78541580
实践效果图:
少一些步骤,以后补上,有人问的话。
但是速度真的很慢。
IDEA更加简单的方法。
直接在项目中,new一个pom.xml即可。内容可以复制其他的项目。代码。然后修改几个参数。
其他就可以使用了。
效果图:应该是成功了。