从IntelliJ调试Grails应用 [英] debugging a Grails app from IntelliJ

查看:75
本文介绍了从IntelliJ调试Grails应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力从IntelliJ内部调试Grails 2.5.0应用程序。具体来说,我发现很难配置应用程序,使得

I've been struggling to debug a Grails 2.5.0 app from inside IntelliJ. Specifically, I'm finding it difficult to configure the app such that


  1. 功能测试可以调试

  2. 可以运行功能测试

  3. 可以调试应用

  4. 可以运行应用

  1. functional tests can be debugged
  2. functional tests can be run
  3. the app can be debugged
  4. the app can be run

当从IntelliJ内部(版本14.1.4)启动(1)和(2)时。

when (1) and (2) are launched from inside IntelliJ (version 14.1.4).

这里是<我用来调查此问题的a href = https://github.com/domurtag/multi-col-constraint-bug rel = noreferrer>玩具Grails应用,该问题具有单个功能测试。调试工作的关键似乎是这些JVM分支设置 BuildConfig.groovy

Here's a toy Grails app I'm using to investigate this issue, which has a single functional test. The key to getting debugging working seems to be these JVM forking settings BuildConfig.groovy.

grails.project.fork = [
        // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
        //  compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],

        // configure settings for the test-app JVM, uses the daemon by default
        test   : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon: true, jvmArgs: jvmArgs],
        // configure settings for the run-app JVM
        run    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false, jvmArgs: jvmArgs],
        // configure settings for the run-war JVM
        war    : [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve: false],
        // configure settings for the Console UI JVM
        console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

// Include the line below to debug functional tests from IntelliJ. The tests should be launched in Debug mode from IntelliJ
//grails.project.fork = null



< h2> Debug run-app(3)

启用分叉后,可以通过从IntelliJ内部运行该应用程序进行调试,然后从IDE启动远程调试器以进行连接到端口5005上的应用程序。JVM分支设置可确保应用程序始终在启用远程调试的情况下运行,因此请确保通过运行而不是 debugging 来启动应用

要调试功能测试,您需要包括此行

To debug functional tests, you need to include this line

grails.project.fork = null

,例如,分叉(和远程调试被禁用。然后您可以通过IntelliJ调试配置启动测试来调试功能测试)

such that forking (and remote debugging is disabled. Then you can debug the functional tests by launching the test via an IntelliJ debug configuration.

根据要调试的是应用程序还是功能测试,必须包含/注释该行相当繁琐,所以我正在寻找更简单的方法解决方案。

It's fairly tedious to have to include/comment out this line depending on whether it's the app or a functional test that's being debugged, so I'm looking for a simpler solution.

如果可能,

if (Environment.current == Environment.TEST) {
    grails.project.fork = null
}

但是由于某些未知原因,这是行不通的。

But for some unknown reason, this does not work.

推荐答案

我在<$中有以下设置c $ c> BuildConfig.groovy :

grails.project.fork = [

    // configure settings for the test-app JVM, uses the daemon by default
    test: false, // see http://youtrack.jetbrains.com/issue/IDEA-115097
    // configure settings for the run-app JVM
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    // configure settings for the run-war JVM
    war: false,
    // configure settings for the Console UI JVM
    console: false
]

您将需要在intellij中添加2个运行配置:

You will need to add 2 run configurations in intellij:


  • 为grails项目添加新的运行配置。使用 run-app --debug-fork 作为命令行。

  • 添加新的远程调试配置。只需使用默认设置即可。

  • Add a new Run Configuration for your grails project. Use run-app --debug-fork as command line.
  • Add a new remote debug configuration. Just use the default settings.

要调试应用,请运行第一个配置。 grails应用程序将启动,并应在地址:5005 上显示监听运输dt_socket。看到此消息后,运行调试配置...

To debug you app, run the first configuration. The grails app will start and should print Listening for transport dt_socket at address: 5005. Once you see this message, run the debug configuration...

让我知道是否需要屏幕截图

Let me know if you need screenshots

这篇关于从IntelliJ调试Grails应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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