如何将第三方 jar 添加到本地 Maven 存储库中? [英] How do I add third-party jars into local Maven repository?

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

问题描述

我有一个包含 4 个 jar 的库:

I have a library consisting of 4 jars:

matlabcontrol-4.1.0.jar
matlabcontrol-4.1.0-javadoc.jar
matlabcontrol-4.1.0-sources.jar
matlabcontrol-demo-4.1.0.jar

如何将它们添加到本地存储库,以便 Maven 知道源在哪里以及 javadoc 在哪里?

How do I add them to the local repository so that Maven knows where sources are and where javadoc is?

此处的文档 http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html 很简短,没有回答这个问题.

Documentation here http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html is very brief and does not answer this question.

推荐答案

文档中明确提到了方式.想想你的 matlabcontrol-4.1.0.jar 在 C:> 位置.因此,将您的 cmd 移动到 C:> 位置并运行以下命令.

The documentation clearly mentioned the way. Think your matlabcontrol-4.1.0.jar in C:> location. So move your cmd on C:> location and run following command.

mvn install:install-file -Dfile=matlabcontrol-4.1.0.jar -DgroupId=org.matlabcontrol 
    -DartifactId=matlabcontrol -Dversion=4.1.0 -Dpackaging=jar

如果你这样做,你可以通过依赖访问你的 jar 文件,比如:

If you do that, you can access your jar file with dependency, like:

 <dependency>
        <groupId>org.matlabcontrol</groupId>
        <artifactId>matlabcontrol</artifactId>
        <version>4.1.0</version>
 </dependency>

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

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