国产探花免费观看_亚洲丰满少妇自慰呻吟_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 倉庫的環境變量來消除這個警告,如果你覺得有這個必要。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴彦淖尔市| 大化| 乳山市| 阿图什市| 苍山县| 罗定市| 普格县| 响水县| 深州市| 醴陵市| 和静县| 酒泉市| 观塘区| 侯马市| 包头市| 渭南市| 新丰县| 阳城县| 梁河县| 庄河市| 资源县| 女性| 西峡县| 安平县| 额尔古纳市| 新余市| 历史| 英超| 尼玛县| 澄城县| 正阳县| 西乌珠穆沁旗| 炉霍县| 望谟县| 长顺县| 镶黄旗| 永康市| 南阳市| 南阳市| 邵武市| 商河县|