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

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

问题描述

在我的 J2EE 项目中,我有几个依赖项,它们在任何 Maven 存储库中都不可用,因为它们是专有库.这些库需要在运行时可用,因此必须复制到 target/.../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 ...

现在,我在我的 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:如何将代表中不可用的 jar 包含到 J2EE 项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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