向maven本地仓库手动导入jar包

向maven本地仓库手动导入jar包


步骤

  1. 将jar包放在指定位置 。路径中不要有空格,有空格的话会报错

    Windows路径
    C:\Users\DossS\Desktop
    
    Linux路径
    $HOME/Downloads/messageUtil/touch-sms-api.jar

     

  2. 打开cmd,输入如下命令
    Windows命令:
    mvn install:install-file 
    -Dfile=C:\Users\DossS\Desktop\touch-sms-api.jar     // jar包路径
    -DgroupId=com.wondersgroup.frame.common.touch-sms-api     
    -DartifactId=touch-sms-api     
    -Dversion=1.0 
    -DgeneratePom=true 
    -Dpackaging=jar
    
    Linux命令:
    mvn install:install-file 
    -Dfile=$HOME/Downloads/messageUtil/touch-sms-api.jar     // jar包路径
    -DgroupId=com.wondersgroup.frame.common.touch-sms-api 
    -DartifactId=touch-sms-api 
    -Dversion=1.0 
    -DgeneratePom=true 
    -Dpackaging=jar
  3. 在maven项目的pom.xml中添加对应依赖
    <dependency>
        <groupId>com.wondersgroup.frame.common.touch-sms-api</groupId>
        <artifactId>touch-sms-api</artifactId>
        <version>1.0</version>
    </dependency>

  1. Windows下最好将jar包放在c盘目录下,否则可能报错,如下图所示。
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.154 s
    [INFO] Finished at: 2018-09-10T13:16:13+08:00
    [INFO] Final Memory: 7M/245M
    [INFO] ------------------------------------------------------------------------
    [ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\DossS). 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/MissingProjectException

     

  2. 注意maven settings.xml配置的localRepository路径,因为idea可以使用其他路径下的仓库,因此可能找不到指定的仓库
  3. 手动输入的命令参数要全

参考文献

 操作步骤

https://blog.csdn.net/qq_36745087/article/details/79229191

https://blog.csdn.net/u012898245/article/details/79210635

报错原因

https://bbs.csdn.net/topics/390776321

https://stackoverflow.com/questions/21497607/install-maven-jar-with-pom-into-local-repository

http://maven.apache.org/plugins/maven-install-plugin/examples/custom-pom-installation.html


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值