调试Grails 3.x应用程序

时间:2015-04-23 14:16:09

标签: grails grails-3.0

我正在尝试使用grails run-app --debug-fork调试Grails 3.x应用程序。但是当应用程序启动时,它不会等待调试器附加。关于如何调试Grails 3.x应用程序的任何解决方案?

4 个答案:

答案 0 :(得分:21)

请使用String[] myFields = new String[]{name, userID, email}; // put your fields in an array or list // loop through each field and copy the data for (String field : myFields) { byte[] stringBytes = field.getBytes(); // get bytes from string System.arraycopy(stringBytes, 0, myByteArr, bufferPosition, stringBytes.length); // copy src to dest bufferPosition += stringBytes.length; // advance index } 标志。 例如:--debug-jvm

答案 1 :(得分:10)

在IntelliJ中,您可以右键单击Gradle任务bootRun并选择Debug。

答案 2 :(得分:3)

另一个选项是直接运行位于grails-app/init的{​​{3}}类。它有static void main并作为常规应用程序运行。您可以使用调试配置文件直接从IDE运行它。

答案 3 :(得分:2)

在IntelliJ IDEA 2016.1中,我创建了两个配置。这使我可以充分利用IntelliJ IDEA提供的所有上下文菜单等。以下是:

  1. 第一个配置是"运行"组态。编辑默认值 配置和"命令行"字段,输入 run-app --debug-jvm
  2. 第二种配置是" Remote"组态。在"运行/调试"对话框,单击+符号并选择" Remote"来自 名单。将其命名为" Debug"并保存。
  3. 选择你的"运行"从顶部的配置下拉列表中进行配置,然后单击绿色箭头以运行该应用程序。监控控制台 输出,直到看到消息 Listening for transport dt_socket at address: 5005
  4. 选择您在步骤2中创建的远程调试配置文件,然后单击调试按钮。稍后控制台输出会说 Grails application running at http://localhost:8080 in environment: development
  5. 成功!

相关问题