如何让 Eclipse 和 mvn appengine:devserver 相互通信?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13924990/
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
How do I make Eclipse and mvn appengine:devserver talk to each other?
提问by antony.trupe
I am in the process of switching from Google Plugin for Eclipseto the official Google App Engine Maven Plugin.
The last thing, I hope, that I cannot figure out is how to get a good debug workflow set up. When I was using GPE, I just set breakpoints and the debugger stopped there automagically, but when I run the dev server via mvn appengine:devserver
, I don't think the dev server and eclipse are aware of each other.
我正在从Google Plugin for Eclipse切换到官方 Google App Engine Maven Plugin。我希望,我无法弄清楚的最后一件事是如何设置良好的调试工作流程。当我使用 GPE 时,我只是设置了断点,调试器会自动停在那里,但是当我通过 运行开发服务器时mvn appengine:devserver
,我认为开发服务器和 eclipse 并不知道彼此。
How do I make them talk to each other?
我如何让他们互相交谈?
采纳答案by antony.trupe
I roughly follow the steps @ developers.google.com/appengine/docs/java/webtoolsplatformin favor of my previous method.
我大致按照@ developers.google.com/appengine/ docs/java/webtoolsplatform 的步骤来支持我以前的方法。
回答by antony.trupe
The first option is to set up your project to use WTP as documented @ https://cloud.google.com/appengine/docs/java/webtoolsplatform. This is the method I switched to.
第一个选项是将您的项目设置为使用 WTP,如@ https://cloud.google.com/appengine/docs/java/webtoolsplatform 中所述。这是我改用的方法。
The second option is to use two debug configurations.
第二个选项是使用两个调试配置。
The first debug configuration will run your maven target, namely appengine:devserver
.
第一个调试配置将运行您的 maven 目标,即appengine:devserver
.
The second is a Remote Java Application
configuration, and will connect the debug client to the devserver jvm.
第二个是Remote Java Application
配置,将调试客户端连接到 devserver jvm。
This also requires some jvm args to be passed to the maven goal.
这也需要将一些 jvm args 传递给 maven 目标。
<!-- GAE plugin -->
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.7.5-SNAPSHOT</version>
<configuration>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=y
</jvmFlag>
</jvmFlags>
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
Once those 3 things are in place, run the maven debug configuration, then run the debug client configuration, then exercise your application.
完成这 3 件事后,运行 maven 调试配置,然后运行调试客户端配置,然后运行您的应用程序。
There is no support for hotswap yet, so if you change any non-resource files(any java source), the devserver will not see them. Resource files will get deployed(static files: html, js).
目前尚不支持热交换,因此如果您更改任何非资源文件(任何 Java 源代码),开发服务器将看不到它们。将部署资源文件(静态文件:html、js)。
回答by appbootup
You should be executing mvnfrom eclipsein debug mode.
您应该在调试模式下从Eclipse执行mvn。
In Eclipse you can configure such maven build commands from eclipse top toolbar "Run" -> "Debug Configuration" -> "Maven Build"
在 Eclipse 中,您可以从 Eclipse 顶部工具栏“运行”->“调试配置”->“Maven 构建”配置此类 maven 构建命令
Once in maven is launched in eclipse debug mode you should be able to hit the breakpoints.
在 Eclipse 调试模式下启动 maven 后,您应该能够命中断点。
Edit- One other option is to set up Remote Debug i.e "Run" -> "Debug Configuration" -> "Remote Java Application"and listen remote debug port i.e You should ensure appengine:devserver launches with remote debug port arguments - Reference - Remote Debugging in eclipse
编辑- 另一种选择是设置远程调试,即“运行”->“调试配置”->“远程 Java 应用程序”并监听远程调试端口,即您应该确保 appengine:devserver 使用远程调试端口参数启动 - 参考 -远程在eclipse中调试
回答by H-H
This questionmay give you a hint of the problem. The Maven appengine:devserver starts the development server on a separate process. Eclipse however is only aware of the Maven process itself (this is what you see in the debug view). In addition, since the dev server cannot be started with arguments such as a debug port, it probably can never be connected to a debugger.
这个问题可能会给你一个问题的暗示。Maven appengine:devserver 在单独的进程上启动开发服务器。然而,Eclipse 只知道 Maven 进程本身(这是您在调试视图中看到的)。此外,由于无法使用调试端口等参数启动开发服务器,因此它可能永远无法连接到调试器。
The question linked suggest that there's an unofficial Maven GAE plugin which takes arguments. There's also a new ticket to enhance the official plugin and a promise by the plugin developper to implement this feature soon.
链接的问题表明有一个非官方的 Maven GAE 插件需要参数。还有一张新票来增强官方插件,插件开发者承诺很快就会实现这个功能。
回答by MattStep
I'll see what else I can do to make the eclipse integration easier, but there is now an update to the issue filed to the appengine-maven-plugin project : http://code.google.com/p/appengine-maven-plugin/issues/detail?id=3&can=1so take a look and see if the support for the jvm arguments can help you out.
我会看看我还能做些什么来使 eclipse 集成更容易,但现在提交给 appengine-maven-plugin 项目的问题有一个更新:http: //code.google.com/p/appengine-maven -plugin/issues/detail?id=3&can=1所以看看对 jvm 参数的支持是否可以帮助你。
Please let me know your experiences, I'm always in favor of things being awesome.
请让我知道你的经历,我总是赞成事情变得很棒。
回答by markvgti
Answer Relevant in 2015
2015年相关回答
I created a GAE (Java) project in Sep 2015 and the following applies to this and similar projects.
我在 2015 年 9 月创建了一个 GAE (Java) 项目,以下内容适用于该项目和类似项目。
I started by creating my project as on ordinary GAE maven project using the Skeleton archetype by simply following the relevant steps from Using Apache Maven - Java — Google Cloud Platform. Followed through from Requirementsthrough to Testing your app with the development server.
我首先使用 Skeleton 原型创建我的项目,就像在普通 GAE maven 项目上一样,只需按照使用 Apache Maven-Java — Google Cloud Platform 中的相关步骤进行操作。从需求一直到使用开发服务器测试您的应用程序。
After that I imported this project into Eclipse JEE (Mars) using "Import an existing Maven project". Started development.
之后,我使用“导入现有 Maven 项目”将此项目导入 Eclipse JEE (Mars)。开始开发。
When I needed to debug, I only had to carry out the few steps explained below.
当我需要调试时,我只需要执行下面解释的几个步骤。
Create a debug configuration
创建调试配置
Go to Run -> Debug Configurations, click on Remote Java Applicationand create a new configuration by clicking on the Newbutton (see screenshot, upper left corner above filter text box).
转到Run -> Debug Configurations,单击Remote Java Application并通过单击New按钮创建一个新配置(参见屏幕截图,过滤器文本框上方的左上角)。
Fill in the details by choosing your particular project and giving a suitable name to the configuration as shown below (let port be 8000) and click Apply:
通过选择您的特定项目并为配置指定合适的名称来填写详细信息,如下所示(让端口为 8000),然后单击Apply:
Uncomment some lines in pom.xml
取消注释 pom.xml 中的一些行
In your project's pom.xml, find the configuration for plugin appengine-maven-plugin
and uncomment the following lines:
在项目的 pom.xml 中,找到插件的配置appengine-maven-plugin
并取消注释以下几行:
<jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
</jvmFlags>
Run the mvn appengine:devserver
command from the command line
mvn appengine:devserver
从命令行运行命令
As the title says...
正如标题所说...
Attach the debugger from within Eclipse
从 Eclipse 中附加调试器
Click on the little down-triangle next to the button for Debugand choose the name of the debug configuration you just set up ("HelloWorldServlet" in my example).
单击“调试”按钮旁边的小三角形,然后选择您刚刚设置的调试配置的名称(在我的示例中为“HelloWorldServlet”)。