Eclipse Web 项目依赖项 [英] Eclipse Web Project Dependencies
问题描述
这个问题是关于 Eclipse 开发的,我试图在 Eclipse 中创建一个 Web 应用程序,问题是我没有将依赖 jars 获取到部署的存档中.
我创建了一个新的动态 Web 项目并将其链接到另一个 Java 项目.Java 项目引用了一些 3rd 方 jar(例如 Spring jar),但由于某些原因,在发布 Web 项目时,我只在 war 的 lib 目录中获得了 Java 项目 jar,而没有 Java 项目依赖项(例如 Spring).>
换句话说,我有项目 A(Web 项目)依赖于项目 B(Java 项目),项目 B 依赖于 Spring jar.当我将 web 项目作为 war 发布到 JBoss 时,只有项目 B 被打包到 jar 中(没有 spring jars)
我知道我可以用ant来做,我什至有这样的build.xml
来构建整个应用程序,但我认为eclipse也可以为我执行打包任务.
我将 Java 项目添加到 Web 项目中的 Java EE 模块依赖项中.
我应该在 Java 项目构建路径属性中使用导出选项吗?我是否应该将 Java 项目的依赖项也添加到 Web 项目中?
我做错了什么?
编辑:我使用的是 Eclipse 3.5.1
- 转到网络项目属性.
- 部署组件(左).
- 添加 > 选择项目 > 选择您的 lib 项目 > 如果未选中,请选中将项目组装到 Web 应用程序的 WEB-INF/lib 文件夹中"> 完成.
- Java 构建路径(左)> 项目选项卡 > 添加... > 选择您的 lib 项目 > 确定
- Java 构建路径(左)> 订购和导出选项卡 > 选择您的 lib 项目.
- 保存
- 现在可以使用了.
This question is about Eclipse development, I am trying to create a web application in Eclipse, the problem is that I don't get the the dependencies jars to the deployed archive.
I've created a new dynamic web project and linked it to another Java project. The Java project references a few 3rd party jars (e.g. Spring jars) but for some reasons when publishing the web project I get only the Java project jar in the lib dir of the war, without the Java project dependencies (e.g.Spring).
In other words, I have project A (web project) that depends on project B (Java Project), project B depends on Spring jars. When I publish the web project as a war to JBoss only project B is packaged into the jar (no spring jars)
I know I can do it with ant, I even have such build.xml
to build the whole app, but I thought eclipse can also perform the packaging task for me.
I added the Java project to the Java EE module dependencies in the web project.
Should I use the export option in the Java project build path properties? should I add the dependencies of the Java project to the web project as well?
What am I doing wrong?
Edit: I am using Eclipse 3.5.1
- Go to web project properties.
- Deployment Assembly (Left).
- Add > Select project > Select your lib project > Check "Assemble projects into the WEB-INF/lib folder of the web application" if not checked > Finish.
- Java Build Path (Left) > Projects Tab > Add... > Select your lib project > OK
- Java Build Path (Left) > Order and Export Tab > Select your lib project.
- Save
- Now it works.
这篇关于Eclipse Web 项目依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!