问题描述
如何将本地 jar 文件(还不是 Maven 存储库的一部分)直接添加到我项目的库源中?
How do I add local jar files (not yet part of the Maven repository) directly in my project's library sources?
推荐答案
将 JAR 安装到您的本地 Maven 存储库(通常是您的主文件夹中的 .m2
),如下所示:
Install the JAR into your local Maven repository (typically .m2
in your home folder) as follows:
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
其中每个指的是:
:要加载的文件的路径,例如 →
c:kaptcha-2.3.jar
<path-to-file>
: the path to the file to load e.g → c:kaptcha-2.3.jar
:文件应该注册的组,例如 →
com.google.code
<group-id>
: the group that the file should be registered under e.g → com.google.code
:文件的工件名称,例如 →
kaptcha
<artifact-id>
: the artifact name for the file e.g → kaptcha
:文件的版本,例如 →
2.3
<version>
: the version of the file e.g → 2.3
:文件的打包方式,例如→
jar
<packaging>
: the packaging of the file e.g. → jar
参考
- Maven 常见问题解答:我有一个 jar,想放入我的本地存储库.如何复制?
- Maven 安装插件使用:
install:install-file
目标
这篇关于如何将本地 jar 文件添加到 Maven 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!