Maven:如何将reps中没有的jar包含到J2EE项目中? [英] Maven: How to include jars, which are not available in reps into a J2EE project?

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

问题描述

在我的J2EE项目中,我有几个依赖项,这些依赖项在任何Maven存储库中都不可用,因为它们是专有库。这些库需要在运行时可用,因此必须复制到目标/.../ WEB-INF / lib ...

in my J2EE project I've a couple of dependencies, which are not available in any Maven repository, because they're proprietary libraries. These libraries need to be available at runtime, so that have to be copied to target/.../WEB-INF/lib ...

现在,我' m将它们列为我的POM中的系统依赖项,但是使用此方法的问题是,在编译期间不会将其复制到目标构建。此方法也不是很优雅。

Right now, I'm listing them as system dependency in my POM, but with this method the problem is, that aren't being copied to the target build during compilation. Also this method is not very elegant.

那么将它们集成到Maven中的最佳方法是什么?

So which is the best way to integrate them in Maven?

注意:我不想创建自己的Maven存储库。

Note: I don't want to create my own Maven repository.

推荐答案

正如你所说的你不想设置你自己的存储库,也许这会有所帮助。

As you've said you don't want to set up your own repository, perhaps this will help.

你可以使用安装文件目标,用于将文件安装到本地存储库。如果您为每个文件创建一个带有Maven调用的脚本并将其与jar放在一起,那么您(以及其他任何有访问权限的人)可以轻松地将jar(和相关的pom文件)安装到其本地存储库中。

You can use the install-file goal of the maven-install-plugin to install a file to the local repository. If you create a script with a Maven invocation for each file and keep it alongside the jars, you (and anyone else with access) can easily install the jars (and associated pom files) to their local repository.

例如:

mvn install:install-file -Dfile=/usr/jars/foo.jar -DpomFile=/usr/jars/foo.pom
mvn install:install-file -Dfile=/usr/jars/bar.jar -DpomFile=/usr/jars/bar.pom

或只是

mvn install:install-file -Dfile=ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0 -Dpackaging=jar

然后,您可以在项目中正常引用依赖项。

You can then reference the dependencies as normal in your project.

然而,您最好的选择仍然是设置内部远程存储库,我建议自己使用 Nexus 。如果需要,它可以在您的开发盒上运行,并且开销很小。

However your best bet is still to set up an internal remote repository and I'd recommend using Nexus myself. It can run on your development box if needed, and the overhead is minimal.

这篇关于Maven:如何将reps中没有的jar包含到J2EE项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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