有时我们要用的 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

相关文章:

  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2017-11-28
  • 2021-12-05
  • 2021-10-03
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
相关资源
相似解决方案