Eclipse WAR有2个项目? [英] Eclipse WAR with 2 projects?

查看:111
本文介绍了Eclipse WAR有2个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Eclipse导出WAR文件。我有一个动态Web项目。但是我需要为其他两个项目创建一个类,一个是普通的Java项目,另一个是Web项目。因此,在Build Config中,我告诉它添加其他项目,然后在 Order and Export页面上单击框以导出第二个和第三个项目。在Eclipse中运行良好,显然可以毫无问题地找到其他项目中的文件。但是,当我导出时,WAR文件中仅包含第一个项目中的文件。

I am trying to export a WAR file from Eclipse. I have a "Dynamic Web Project". But I need classes created for two other projects, one a plain Java project, the other another web project. So in the Build Config I told it to add the other projects and on the "Order and Export" page I clicked the boxes to export the second and third projects. In runs fine within Eclipse, apparently finds the files from the other projects with no problem. But when I export, only the files from the first project are included in the WAR file.

如何使Eclipse将其他项目的文件包含在WAR中?显然,仅将它们添加到Build Config中并标记为导出是不够的。是否存在问题,因为其他项目之一也是Web项目? Eclipse是否对此表示反对?

How do I get Eclipse to include the other projects' files in the WAR? Apparently just adding them to the Build Config and marking for export isn't enough. Is there a problem because one of the other projects is also a web project? Does Eclipse balk at that?

我想我可以通过将需要的文件从其他项目复制到第一个文件来完成这项工作。但是,无论何时更新它们,我都必须知道这已经发生并复制新版本。那会很痛苦,我认为这就是Eclipse项目的目的,因此我可以在应用程序之间共享文件。

I presume I could make this work by copying the files I need from the other projects to the first. But then any time they are updated, I would have to know that this had happened and copy the new versions. That would be a pain, and I thought that's what Eclipse projects were for, so I could share files between applications.

编辑

让我澄清一下,我不想部署2个WAR。我为一个项目编写了一个Web应用程序,其中包括一些我想在另一个项目上重用的类。我试图做的就是在真实的 WAR中选这几节课。我绝对不想部署2个WAR,因为它可能与原始项目位于同一服务器上,并且我也不想覆盖原始项目的现有WAR。

Let me clarify that I don't want to deploy 2 WARs. I have a web app written for one project that includes some classes that I want to re-use on another project. What I was trying to do was just pick up those couple of classes in the "real" WAR. I definately don't want to deploy 2 WARs because this might go on the same server as the original project, and I don't want to overwrite the existing WAR of the original project.

感谢您的帮助!

推荐答案

您需要将其他项目作为Java EE模块添加到您的Web项目中。右键单击您的Web项目->属性-> Java EE模块依赖关系。在其中添加其他项目。 Eclipse将在导出中包含此项目。

You need to add your other project as a Java EE module to your web project. Right click on your web project -> properties -> Java EE module Dependencies. Add the 'other' project to it. Eclipse will include this project in the export.

这篇关于Eclipse WAR有2个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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