如何将本地 jar 文件添加到 Maven 项目? [英] How to add local jar files to a Maven project?

查看:36
本文介绍了如何将本地 jar 文件添加到 Maven 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将本地 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

参考

这篇关于如何将本地 jar 文件添加到 Maven 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆