我需要 Eclipse 来部署我的 ANT 脚本构建的 WAR 文件,而不是它内部构建的 [英] I need Eclipse to deploy the WAR file my ANT script builds, not what it builds internally

查看:26
本文介绍了我需要 Eclipse 来部署我的 ANT 脚本构建的 WAR 文件,而不是它内部构建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Eclipse Helios.我有一个动态 Web 项目,我已经设置 Eclipse 以使用 Ant Builder 生成 WAR 文件.这一切正常;如果我更改 .java 文件,Eclipse 会通过 Ant 自动运行我的 build.xml 并更新我的 WAR.如果我将 WAR 部署到 Tomcat 的外部实例,它会完美运行.

I'm using Eclipse Helios. I have a dynamic web project going and I've set up Eclipse to use an Ant Builder to generate a WAR file. This all works fine; if I change a .java file, Eclipse automatically runs my build.xml via Ant and updates my WAR. If I deploy the WAR to an external instance of Tomcat, it works perfectly.

但是,当我告诉 Eclipse 在 Tomcat 下运行我的项目时,它没有使用 Ant 构建生成的 WAR 文件,或者使用我的 Ant 脚本生成临时 WAR.

However, when I tell Eclipse to run my project under Tomcat, it is not using the WAR file generated by the Ant build, or using my Ant script to generate a temporary WAR.

我知道这一点是因为我的 build.xml 脚本在 WAR 的 WEB-INF/classes 中包含了一些额外的 XML 配置文件,这些文件并没有出现在 Eclipse 推出的 WEB-INF/classes 目录中.

I know this because my build.xml script includes some additional XML configuration files in WEB-INF/classes in the WAR that are not ending up in the WEB-INF/classes dir that Eclipse pushes out.

我似乎在 Eclipse 中找不到任何说发布时,使用此 WAR 文件而不是构建自己的文件"的内容.

I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".

另一种方法是在构建 WAR 时通过添加文件列表告诉 Tomcat 这样做,但我似乎也找不到这样做的方法.

An alternate approach would be to tell Tomcat when it is building a WAR to do so by adding a list of files, but I can't seem to find a way to do that either.

我也很好奇 Eclipse 如何知道要发布什么,因为它显然忽略了我的 build.xml 和我之前生成的 WAR 文件.

I'm also curious how Eclipse knows what to publish since it is obviously ignoring my build.xml and my previously-generated WAR file.

推荐答案

Eclipse 通过查看项目的 Web 部署程序集选项来部署 Web 应用程序.您可以通过右键单击项目,选择属性",然后单击部署程序集"来查看这一点.Eclipse 通常在这里使用扩展目录部署,而不是创建和部署 WAR(这是基于正在使用的服务器插件,但我认为它们中的大多数使用扩展目录结构以提高速度).如果您导出为 WAR,它将创建一个具有相同内容的 WAR.

Eclipse deploys a web application by looking at the Web Deployment Assembly options for your project. You can see this by right-clicking the project, choosing Properties, and then click on Deployment Assembly. Eclipse usually uses an expanded directory deployment here rather than creating and deploying a WAR (this is based on the server plugin being used, but I think most of them use an expanded directory structure for speed). If you export as a WAR it will create a WAR with the same content.

有两种主要选择可以做您想做的事:

There are two main choices to do what you'd like:

  • 修改 Web 部署程序集选项以与您在部署的应用程序中想要的完全匹配

  • Modify the Web Deployment Assembly options to match exactly what you would like in the deployed app

不要使用Eclipse的部署;将External Ant Builder"添加到项目的Builders"选项中(右键单击项目,选择 Properties->Builders).然后就可以在 Eclipse 构建项目时选择要使用的 ant 文件中的哪些目标.这些选项之一可以是部署步骤

Don't use Eclipse's deployment; add an "External Ant Builder" to the "Builders" options for your project (right-click project, choose Properties->Builders). You can then select which targets in the ant file you want to use when eclipse builds the project. One of these options can be a deployment step

这篇关于我需要 Eclipse 来部署我的 ANT 脚本构建的 WAR 文件,而不是它内部构建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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