从 Eclipse 快速调试 Flex/Java Web 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4426053/
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:28:36  来源:igfitidea点击:

Quickly debug Flex/Java web application from Eclipse?

javaapache-flexeclipsedebuggingmaven-2

提问by HDave

I have a Flex/Java web application that uses Maven as a build tool. Currently, if I want to debug the entire application I use Maven to create the WAR file and use the cargo plugin to deploy the WAR file and start up the app server. I then launch an Eclipse (with Flash Builder 4) Flex "Web Application" debug configuration and start debugging.

我有一个使用 Maven 作为构建工具的 Flex/Java Web 应用程序。目前,如果我想调试整个应用程序,我使用 Maven 来创建 WAR 文件并使用货物插件来部署 WAR 文件并启动应用服务器。然后我启动一个 Eclipse(使用 Flash Builder 4)Flex“Web 应用程序”调试配置并开始调试。

It all works very well, but I am looking for a way to make this faster. I'd like to be able to edit my Flex code and immediately launch my Flash Builder debug configuration without going through Maven.

这一切都很好,但我正在寻找一种方法来加快速度。我希望能够在不通过 Maven 的情况下编辑我的 Flex 代码并立即启动我的 Flash Builder 调试配置。

Currently the output folder for my Flex client module is just the "bin" folder of the project. In a perfect world, I'd configure Flash Builder to put it's newly minted SWF file (and assets) directly into the app server I am running. Assuming this is impossible with remote app servers, and also impossible with the local app servers I run from Cargo, perhaps I can use another approach to running a local app server from Eclipse?

目前,我的 Flex 客户端模块的输出文件夹只是项目的“bin”文件夹。在一个完美的世界中,我会配置 Flash Builder 将它新创建的 SWF 文件(和资产)直接放入我正在运行的应用程序服务器中。假设这对于远程应用服务器是不可能的,对于我从 Cargo 运行的本地应用服务器也是不可能的,也许我可以使用另一种方法从 Eclipse 运行本地应用服务器?

I don't know enough about Eclipse or Flash Builder to know what to do...HELP!

我对 Eclipse 或 Flash Builder 的了解不够,不知道该怎么做...帮助!

回答by Malcolm Featonby

We are using Flash Builder but this should work for the eclipse plugin too. In the Flex Build Path configuration for the project set the output folder to the target folder where you have your web server pick up the SWF you are building. Set the Output folder URL to point to the context that launches the SWF and you should be good to go. Example:

我们正在使用 Flash Builder,但这也适用于 eclipse 插件。在项目的 Flex Build Path 配置中,将输出文件夹设置为目标文件夹,您可以在该文件夹中让 Web 服务器获取正在构建的 SWF。将输出文件夹 URL 设置为指向启动 SWF 的上下文,您应该很高兴。例子:


Output folder: c:\java\tomcat\webapps\myapp
Output folder URL: http://localhost:8080/myapp


输出文件夹:c:\java\tomcat\webapps\myapp
输出文件夹 URL:http://localhost:8080/myapp

As an aside we have also found that using IE to test in makes things simpler as it tends to have less funnies with cached SWFs then Firefox or Chrome.

顺便说一句,我们还发现使用 IE 进行测试可以使事情变得更简单,因为与 Firefox 或 Chrome 相比,使用缓存的 SWF 往往没有那么有趣。

回答by Cornel Creanga

I'm using FlashBuilder with the WTP plugin..I'm using the same environment for both Flex and Java. As an application server I'm using Tomcat for the moment, and I configured the output folder like that:

我将 FlashBuilder 与 WTP 插件一起使用。我对 Flex 和 Java 使用相同的环境。作为应用程序服务器,我目前使用 Tomcat,并像这样配置输出文件夹:

${DOCUMENTS}.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myproject

${DOCUMENTS}.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\myproject

Where DOCUMENTS is a linked variable and represents the full path to my workspace: C:\projects\workspace-mypetprojects

其中 DOCUMENTS 是一个链接变量,代表我的工作区的完整路径:C:\projects\workspace-mypetprojects

Everything goes well, I do not have to restart the server or to build a new war when modifying the flex files.

一切顺利,我在修改 flex 文件时不必重新启动服务器或构建新的War。

回答by 2DH

First of all you should download Eclipse for Java EE developers* and install Flash Builder as a plugin, pointing to your existing Eclipse, during installation. Having that you should be able to create Flex project through

首先,您应该为 Java EE 开发人员下载 Eclipse*,并在安装期间将 Flash Builder 作为插件安装,指向您现有的 Eclipse。有了它,您应该能够通过以下方式创建 Flex 项目

File -> New -> Other -> Flex Builder -> Flex Project

Here you need to set Application server typeto J2EE and make sure you have Create combined Java/Flex...option checked. I usually leave Use remote object access serviceoption unchecked as I'm using GraniteDS so it's up to you if you need it or not.

在这里,您需要设置Application server type为 J2EE 并确保Create combined Java/Flex...选中了选项。Use remote object access service当我使用 GraniteDS 时,我通常不选中该选项,因此如果您需要,则由您决定。

On the next screen you need to configure your Application Server. Here are the steps for Tomcat:

在下一个屏幕上,您需要配置应用程序服务器。以下是Tomcat的步骤:

  • Target runtime -> New -> Apache -> <<your preferable Tomcat version>>(change server name and host name to whatever suits you best or - my favorite :) - leave it as it is)
  • Tomcat installation directory should point to where you've installed your Tomcat - by default it is C:\Program Files\Apache Software Foundation\Tomcat 6.0. If you don't have Tomcat installed you can do so by using Download and installwizard
  • On the next screen you're supposed to add web applications you want to have deployed to the server but, as you probably don't have any right now, just press Finish.
  • Select Tomcat server you've just created (you may want to play with rest of the settings like Context root etc.)
  • Next screen and some more settings I usually left default :)
  • Finish
  • Target runtime -> New -> Apache -> <<your preferable Tomcat version>>(将服务器名称和主机名更改为最适合您的名称或 - 我最喜欢的 :) - 保持原样)
  • Tomcat 安装目录应该指向您安装 Tomcat 的位置 - 默认情况下它是C:\Program Files\Apache Software Foundation\Tomcat 6.0. 如果您没有安装 Tomcat,您可以使用Download and install向导来安装
  • 在下一个屏幕上,您应该添加要部署到服务器的 Web 应用程序,但由于您现在可能没有任何应用程序,只需按Finish
  • 选择您刚刚创建的 Tomcat 服务器(您可能想要使用其他设置,例如 Context root 等)
  • 下一个屏幕和更多设置我通常保留默认值:)
  • 结束

Window -> Show view -> Other -> Server -> Servers -> OKwill open servers view where you can manage your Tomcat server. Use RMB on your server name, then Add and remove, select your application, click Addand Finish.

Window -> Show view -> Other -> Server -> Servers -> OK将打开服务器视图,您可以在其中管理 Tomcat 服务器。在您的服务器名称上使用 RMB,然后Add and remove选择您的应用程序,单击AddFinish

Now, 3 icons above the server name and to the right are used to start the server, starting from the left, in debug, normal and profiling mode. Press debug one and server should start - now you will be able to debug Java code you put on the server.

现在,服务器名称上方和右侧的 3 个图标用于启动服务器,从左侧开始,处于调试、正常和分析模式。按调试一键,服务器应该启动——现在您将能够调试您放在服务器上的 Java 代码。

Last step is to start Flex app in debug mode. Below menu bar you can see icons similar to those used to start the server. Press the down arrow located near debug one and select Debug configurations. Double-click Flex Application, change the name of your newly created configuration and correct debug URL to match your server configuration (leave it as it is if you left everything default up to now). Press Applyand Debugand here you are debugging :) Use F5 to step into, F6 to step over and F8 to continue.

最后一步是在调试模式下启动 Flex 应用程序。在菜单栏下方,您可以看到类似于用于启动服务器的图标。按调试一附近的向下箭头并选择Debug configurations。双击Flex Application,更改新创建的配置的名称并更正调试 URL 以匹配您的服务器配置(如果到目前为止您将所有内容保留为默认值,则保持原样)。按ApplyDebug在这里你正在调试:) 使用 F5 进入,F6 跳过,F8 继续。

PS: You may want to change default browser your application is started in (by default it is in-built Eclipse browser I think). You do that by going to Window -> Preferences -> General -> Web Browser.

PS:您可能想要更改启动应用程序的默认浏览器(我认为默认情况下它是内置的 Eclipse 浏览器)。你通过去做到这一点Window -> Preferences -> General -> Web Browser

Happy debugging :)

调试愉快:)

* unfortunatelly I'm using older version of the IDE so above steps may be slightly different than what you have in your Eclipse but you should get general idea. Also Flex Builder 3 seems to be incompatible with latest Eclipse releases (Flex Projects are not fond of being created in Helios release)

* 不幸的是,我使用的是旧版本的 IDE,因此上述步骤可能与您在 Eclipse 中的步骤略有不同,但您应该大致了解一下。此外,Flex Builder 3 似乎与最新的 Eclipse 版本不兼容(Flex 项目不喜欢在 Helios 版本中创建)