向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


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章