如何在 WAR 文件中包含依赖项? [英] How to include dependencies in WAR file?
问题描述
我在 Eclipse 中有一个 Dynamic Web 项目
,它依赖于我工作区中的另一个 Java 项目.在内置 Tomcat 服务器中运行 Web 项目时,我已将项目依赖项添加到运行配置中的类路径中.我想创建一个 WAR 来在外部服务器上部署 Web 项目.依赖 Java 项目已添加到 Eclipse 中的 Java 构建路径,但是当我导出 WAR 文件时,该库不包含在内.Java 项目也在Order and Export 中被选中.如何创建包含我的依赖项的 WAR?
I have a Dynamic Web Project
in Eclipse which has a dependency to another Java project in my workspace. When running the web project in the build-in Tomcat server, I've added the project dependency to the class path in the run configuration. I would like to create a WAR for deploying the web project on an external server. The dependency Java project is added to the Java Build path in Eclipse, but when I export an WAR-file the library is not included. The Java project is also selected in the Order and Export. How can I create a WAR with where my dependencies are included?
推荐答案
Maven 多模块项目非常适合这里,
如果你不想这样做,那么只需将依赖项构建到(.jar)中,将其添加到 Web 项目(/WEB-INF/lib)的运行时依赖项中并构建 WAR
If you don't want to go for it then just the build the dependency into (.jar) add it to runtime dependency of web project(/WEB-INF/lib) and build up the WAR
这篇关于如何在 WAR 文件中包含依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!