Eclipse 在 WAR 中导出 JAR

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4631157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:37:16  来源:igfitidea点击:

Eclipse exporting JAR in WAR

javaeclipse

提问by aronp

I have two projects in eclipse, a library project producing a Jar file and a web project dependant on that Jar. How do I get the web project to export the first projects jar in its war automatically. I know this must have been answered before, but I really cant find it.

我在 Eclipse 中有两个项目,一个生成 Jar 文件的库项目和一个依赖于该 Jar 的 Web 项目。如何让 Web 项目自动导出其War中的第一个项目 jar。我知道这之前肯定已经回答过,但我真的找不到。

Thanks,

谢谢,

回答by Thorbj?rn Ravn Andersen

The mechanism to determine what goes in the war is notthe build path as for "normal" applications, but the "Deployment assembly".

确定War中发生什么的机制不是“正常”应用程序的构建路径,而是“部署程序集”。

Right-click on the root node of the dynamic web project, and select Properties, and select Deployment assembly. Here you can add projects (which are jarred up and added to WEB-INF/lib) and individual jars in the project.

右键单击动态Web项目的根节点,选择属性,然后选择部署程序集。您可以在此处添加项目(已打包并添加到 WEB-INF/lib 中)和项目中的各个 jar。



EDIT 2015-08-20: A few years later, Maven has become the standard way to build Java-based software primarily due to the script based approach to dependency management. This includes how to build WAR-files, and the three major IDE's (IntelliJ, Netbeans and Eclipse) fully support this allowing you to switch between IDE's while developing. In Eclipse the problem asked here will not apply, as this is fully controlled by the Maven plugin.

编辑 2015-08-20:几年后,Maven 已成为构建基于 Java 的软件的标准方式,这主要是由于基于脚本的依赖管理方法。这包括如何构建 WAR 文件,并且三个主要的 IDE(IntelliJ、Netbeans 和 Eclipse)完全支持这一点,允许您在开发时在 IDE 之间切换。在 Eclipse 中,这里提出的问题不适用,因为这完全由 Maven 插件控制。