国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

向Maven的本地庫中添加jar文件

2019-11-14 14:57:26
字體:
來源:轉載
供稿:網友

有時我們要用的 maven 依賴項在官方repo庫中找不到,然而我們從其他渠道獲得了依賴項中的所有jar文件,本文記錄了如何向本地庫添加jar文件。

從復雜到簡單,有三種方法:

  1. 使用 maven 的倉庫管理器(例如Nexus)來架設一個本地倉庫服務器
  2. 使用指令 mvn install:install-file 將jar文件安裝到本地倉庫
  3. 通過項目pom配置文件引入

第一種方法有利于團隊開發,內容多一點,我打算單獨用一篇文章記錄。這里介紹其他兩種方法:

 

使用指令 mvn install:install-file 將jar文件安裝到本地倉庫

語法規范:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging> -DgeneratePom=true Where: <path-to-file> the path to the file to load <group-id> the group that the file should be registered under <artifact-id> the artifact name for the file <version> the version of the file <packaging> the packaging of the file e.g. jar

我們以文件<not-yet-commons-ssl-0.3.17.jar>為例:

mvn install:install-file -Dfile=e:/not-yet-commons-ssl-0.3.17.jar -DgroupId=org.apache.commons -DartifactId=not-yet-commons-ssl -Dversion=0.3.17 -Dpackaging=jar -DgeneratePom=true

 

通過項目pom配置文件引入

編輯項目pom文件,在依賴項中增加條目,并指定<scope>和<systemPath>。

還是以文件<not-yet-commons-ssl-0.3.17.jar>為例:

<dependency> <groupId>org.apache.commons</groupId> <artifactId>not-yet-commons-ssl</artifactId> <version>0.3.17</version> <scope>system</scope> <systemPath>e:/not-yet-commons-ssl-0.3.17.jar</systemPath></dependency>

等等,編譯后出現一個警告:

[WARNING] 'dependencies.dependency.systemPath' for org.apache.commons:not-yet-commons-ssl:jar should use a variable instead of a hard-coded path e:/not-yet-commons-ssl-0.3.17.jar @ line 35, column 16
[WARNING]
[WARNING] It is highly recommended to fix these PRoblems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

原來是 maven 苦口婆心地告訴我們不要使用諸如 C:/Windows 這樣的絕對路徑,而應使用 ${java.home} 這樣的相對路徑(變量),否則降低了編譯可重現性,并威脅我們以后可能不再支持這種方式。

嗯,我們可以建立一個 maven 倉庫的環境變量來消除這個警告,如果你覺得有這個必要。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 皋兰县| 隆化县| 丰都县| 濮阳县| 洛阳市| 和田县| 隆化县| 通许县| 麻江县| 睢宁县| 湖州市| 乐亭县| 桂东县| 陆丰市| 汉源县| 鲜城| 宁强县| 图们市| 靖江市| 武清区| 重庆市| 余姚市| 漾濞| 金寨县| 静宁县| 黄山市| 长沙市| 盘山县| 岳阳县| 永清县| 海兴县| 凤翔县| 阿拉尔市| 通海县| 定西市| 叙永县| 宣化县| 高密市| 察隅县| 新平| 青田县|