java 是否可以使用 IntelliJ 9 社区版在远程服务器上调试 GWT 客户端代码?

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

Is it possible to debug GWT client code on a REMOTE server using IntelliJ 9 Community Edition?

javagwtintellij-idea

提问by Nadav

I'm trying to move our Google Web Toolkit (GWT) development from Eclipse to IntelliJ 9 Community edition. So far I've been able to run and debug client/server code successfully via the GWT Maven plugin and its embedded Jetty container.

我正在尝试将我们的 Google Web Toolkit (GWT) 开发从 Eclipse 转移到 IntelliJ 9 社区版。到目前为止,我已经能够通过 GWT Maven 插件及其嵌入式 Jetty 容器成功运行和调试客户端/服务器代码。

However, I'm having trouble debugging client code when it is already running on a remote machine (and hence there's no need for the embedded Jetty container).

但是,当客户端代码已经在远程机器上运行时,我在调试客户端代码时遇到了麻烦(因此不需要嵌入式 Jetty 容器)。

Has anyone been successful at achieving this? Any help would be appreciated!

有没有人成功地实现了这一目标?任何帮助,将不胜感激!

UPDATE: I was finally able to accomplish this. Please see my own answer below...

更新:我终于能够做到这一点。请在下面查看我自己的答案...

回答by Nadav

I was finally able to accomplish this by using GWT's DevModeclass, as described in the documentation.

我终于能够通过使用 GWT 的DevMode类来实现这一点,如文档所述

In short -

简而言之 -

  • Add your project to IntelliJ 9 Community edition
  • Add an Applicationrun/debug configuration
  • Use com.google.gwt.dev.DevModeas your main class (make sure to include gwt-user and gwt-dev jars to the project classpath. See here)
  • Add the following program parameters:

    -noserver-war "[full path to your exploded war]" -gen "[full path to generated files]" -logLevel INFO -port [remote server port] -startupUrl "[URL of the remote page]" [com.company.YourEntryPoint]

  • 将您的项目添加到 IntelliJ 9 社区版
  • 添加应用程序运行/调试配置
  • 使用com.google.gwt.dev.DevMode作为您的主类(确保将 gwt-user 和 gwt-dev jars 包含到项目类路径中。参见此处
  • 添加以下程序参数:

    -noserver -war"[爆炸War的完整路径]" -gen "[生成文件的完整路径]" -logLevel INFO -port [远程服务器端口] -startupUrl "[远程页面的 URL]" [com.company .你的入口点]

This way, the DevMode runner will not instantiate the built in container and will allow your remote server's JavaScript to be debugged in its original Java form.

这样,DevMode 运行程序将不会实例化内置容器,并允许以原始 Java 形式调试远程服务器的 JavaScript。

Note that for builds that don't require debugging remote client code you may use Maven or Ant integration, which is much simpler. I don't have any experience with the webAppCreator generated build.xml, but with Maven you could simply run the gwt:run or gwt:debug goals with this parameter: -DrunTarget=

请注意,对于不需要调试远程客户端代码的构建,您可以使用 Maven 或 Ant 集成,这要简单得多。我对 webAppCreator 生成的 build.xml 没有任何经验,但是使用 Maven,您可以简单地使用以下参数运行 gwt:run 或 gwt:debug 目标:-DrunTarget=

Hope it helps!

希望能帮助到你!

回答by dafmetal

When running a GWT app deployed on a remote server, the client part of your app will have been translated into javascript so I do not think you will be able to debug this from IntelliJ. The server side part of your app will still be Java code. You should be able to start up this remote server with java debugging parameters (things like a transporttype and a port to listen to). From IntelliJ, you should be able to start up a remote debugging session using the same transporttype and port. If you look into remote debugging, you should be able to find how to do this.

当运行部署在远程服务器上的 GWT 应用程序时,应用程序的客户端部分将被转换为 javascript,因此我认为您无法从 IntelliJ 调试它。您的应用程序的服务器端部分仍将是 Java 代码。您应该能够使用 java 调试参数(例如传输类型和要侦听的端口)启动此远程服务器。从 IntelliJ,您应该能够使用相同的传输类型和端口启动远程调试会话。如果您查看远程调试,您应该能够找到如何执行此操作。