window环境使用maven手动安装jar包

来源:互联网 发布:windows10未识别网络 编辑:程序博客网 时间:2024/06/07 10:27

kaptcha-2.3.jar为例

kaptcha-2.3.ja的下载地址点击打开链接

1.将kaptcha-2.3.jar放到C:\Users\Guo目录下
2.window+R--> cd  C:\Users\Guo
3.执行命令 
mvn install:install-file -DgroupId=com.google.code.kaptcha -DartifactId=kaptcha -Dversion=2.3 -Dpackaging=jar -Dfile=kaptcha-2.3.jar
如图:

出现“BUILD SUCCESS” 成功安装

4.打开maven仓库D:\HGDE\maven-dependcies\com\google\code\kaptcha\kaptcha\2.3看到文件列表如下


表示已经成功安装

在pom.xml中配置,就无需再下载kaptcha.jar,直接使用

<dependency>
    <groupId>com.google.code.kaptcha</groupId>
    <artifactId>kaptcha</artifactId>
    <version>2.3</version>
</dependency>

说明,本地使用pom文件下载kaptcha-2.3.jar的时候,一直卡住,只好去maven官网手动下载了kaptcha-2.3.jar,然后自行安装,亲测可用。

-------------------------------------------------------------------------------------------------------------------------------------------------------

今天安装jar包的时候,安装失败,报错信息如下

C:\Users\Guo>mvn install-file -DgroupId=com.ctg.mq -DartifactId=ctgmq-rocketmq-tools -Dversion=2.2.4_P1 -Dpackaging=jar -Dfile=ctgmq-rocketmq-tools-2.2.4_P1.jar[INFO] Scanning for projects...[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 0.087 s[INFO] Finished at: 2017-10-18T14:02:10+08:00[INFO] Final Memory: 6M/155M[INFO] ------------------------------------------------------------------------[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\Guo). Please verify you invoked Maven from the correct directory. -> [Help 1][ERROR][ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR][ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectExceptionC:\Users\Guo>
去网络上找了一下原因,基本都是说两方便的原因:一、jar包的路径不可以有空格,我这里可以确认本地是没有空格,把解决方案给否定;二、需要在c盘根目录下执行,也不行。我只好去查看了本地maven的环境变量,也没问题。那问题还是出在命令上了,翻出来上面成功的截图,果然,命令有错误,漏掉了“install:”,加上之后,执行命令,安装成功。此事提醒我,一定要细心,命令尽量去复制,不要直接手写。

原创粉丝点击