且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven:如何将reps中没有的jar包含到J2EE项目中?

更新时间:2021-07-10 18:30:12

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

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.