如何从lib文件夹中添加Maven依赖jar文件 [英] How to add Maven dependency jar file from the lib folder

查看:431
本文介绍了如何从lib文件夹中添加Maven依赖jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将jar文件添加到项目中的Maven依赖项中。 settings.xml配置为将存储库设置为公共存储库。但是这个特殊的罐子不存在于那个仓库中。由于我的lib文件夹中有jar,我如何配置Maven依赖项来获取此jar?

解决方案

看看在系统依赖关系



您基本上需要定义< scope> system< / scope>

 <项目> 
...
< dependencies>
< dependency>
< groupId> javax.sql< / groupId>
< artifactId> jdbc-stdext< / artifactId>
< version> 2.0< / version>
< scope> system< / scope>
< systemPath> $ {java.home} /lib/rt.jar</systemPath>
< / dependency>
< / dependencies>
...
< / project>

如果您没有自己的托管工件存储库服务器,例如Nexus,Artifactory或Archiva 。



如果你这样做,那么正如Karl-Heinz建议的那样,最好将它放在那里,因为将二进制工件提交给版本控制并不是一种好的做法。 / p>

I am trying to add a jar file to the Maven dependency in my project. The settings.xml is configured to set the repository to a public repository. But this particular jar is not present in that repo. As i have the jar in my lib folder, how can i configure the Maven dependency to take this jar?

解决方案

Have a look at system dependencies.

You basically need to define <scope>system</scope>.

<project>
    ...
    <dependencies>
      <dependency>
        <groupId>javax.sql</groupId>
        <artifactId>jdbc-stdext</artifactId>
        <version>2.0</version>
        <scope>system</scope>
        <systemPath>${java.home}/lib/rt.jar</systemPath>
      </dependency>
    </dependencies>
    ...
</project>

This is if you don't have your own hosted artifact repository server such as Nexus, Artifactory or Archiva.

If you do, then as Karl-Heinz suggested, you would be better off placing it there, as it's not good practice to commit binary artifacts to version control.

这篇关于如何从lib文件夹中添加Maven依赖jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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