maven本地庫更新失敗


當我們在項目中遇到有些依賴在第三方倉庫特別是maven倉庫里面沒有的時候我們會怎么辦?

答案1.通過私服,上傳到公司的一個私服上然后進行下載

答案2.通過本地安裝,這樣非常方面進行使用,今天我們就采用本地安裝的方法。

1.假設我們需要一個jframe.jar 的一個包在我們項目中要用到http服務發送,我們的做法如下:

  1. 使用本地庫安裝命令maven本地庫
mvn install:install-file -Dfile={Path/to/your/jframe.jar} -DgroupId=jframe -DartifactId=jframe -Dversion=1.5 -Dpackaging=jar

  2.出現安裝成功以后就是在項目中引用了直接貼代碼

   <dependency>
            <groupId>jframe</groupId>
            <artifactId>jframe</artifactId>
            <version>${jframe.version}</version>
     </dependency>

  3. 使用編譯命令

mvn clean install -DskipTests

  出現編譯成功

[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ TopicInterface ---
[INFO] Installing /home/joqk/Workspace/TopicInterface/target/TopicInterface-0.0.1.2017220-alpha.jar to /root/.m2/repository/com/thinkit/TopicInterface/0.0.1.2017220-alpha/TopicInterface-0.0.1.2017220-alpha.jar
[INFO] Installing /home/joqk/Workspace/TopicInterface/pom.xml to /root/.m2/repository/com/thinkit/TopicInterface/0.0.1.2017220-alpha/TopicInterface-0.0.1.2017220-alpha.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.088 s
[INFO] Finished at: 2017-04-05T19:23:59+08:00
[INFO] Final Memory: 47M/1567M

 

其他問題:  

1。更新的時候往往出現本地庫的無法更新

一般錯誤信息如下:

was cached in the local repository ,resolution will will not be reattempted until the update interval of central has elapsed or updates are forced

  報錯信息是在緩存在本地的本地庫不會更新了,直到下次更新周期,即使我們進行手動更新命令也無效,就是這種錯誤,一直在進行。

我們進入本地庫找到該庫文件一看究竟:

[root@localhost 1.5]# pwd  /root/.m2/repository/jframe/jframe/1.5

[root@localhost 1.5]# ls
jframe-1.5.jar  jframe-1.5.jar.lastUpdated  jframe-1.5.jar.sha1  jframe-1.5.pom  jframe-1.5.pom.lastUpdated  jframe-1.5.pom.sha1  _remote.repositories

  會看到該庫文件中有許多后綴名為.lastUpdated的文件,打看看一下內容表示在遠程服務器中更新有錯誤,所以就留下了個這個文件。那我們的解決方案是什么呢?

刪除所有這些文件,再次執行 clean install 問題就迎刃而解了。

 

最主要


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM