如何在IntelliJ中调试Maven OpenJFX应用程序 [英] How to debug a Maven OpenJFX application in IntelliJ

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

问题描述

由于JavaFX已经成为OpenJFX,并且需要作为依赖添加到您的Maven项目中,因此调试OpenJFX应用程序变得非常复杂.在这个问题中,它已经是回答了如何为NetBeans解决它.但是IntelliJ的工作方式略有不同.已根据此示例.

Since JavaFX has become OpenJFX and needs to be added as a dependency to your Maven project, debugging a OpenJFX application has become complicated. In this question it is already answered how to solve it for NetBeans. But IntelliJ works slightly different. The Ppom.xml has been setup according to this example.

如何在IntelliJ中以调试模式运行配置为Maven项目的OpenJFX(JavaFX)应用程序?

How can you run an OpenJFX (JavaFX) application which is configured as a Maven project in debug mode in IntelliJ?

推荐答案

如果要复制

If you would copy the addition of VM options in the pom.xml for javafx-maven-plugin as given by José Pereda here, you can run the application with 'mvn javafx:run@debug' and then manually attach it to the IntelliJ Debugger by go to the menu 'Run - Attach to process...' and the select your application.

但是,如果您希望单击一下即可启动调试器和应用程序,则IntelliJ会很麻烦.您可以创建一个远程调试配置,该配置首先按顺序启动您的应用程序和调试器.或具有同时进行的化合物配置".问题是使它们同步.

However, if you want debugger and application to be started with a single click, IntelliJ is a but troublesome. You can create a Remote Debug configuration which first launches your application and the debugger serially. Or have Compound Configurations which does both in parallel. The problem is to get them synchronized.

我找到了以下解决方案.使您的应用程序作为调试客户端运行,而IntelliJ调试器作为服务器运行. pom.xml文件中javafx-maven-plugin的VM选项应具有"server = n":

I found the following solution. Make your application run as debug client and the IntelliJ debugger as server. The VM options for the javafx-maven-plugin in the pom.xml file should have 'server=n':

        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.4</version>
            <executions>
                <execution>
                    <!-- Default configuration for running -->
                    <id>default-cli</id>
                    <configuration>
                        <mainClass>org.waninge.test.JFXTest</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <!-- Configuration for debugging -->
                    <id>debug</id>
                    <configuration>
                        <options>
                            <option>-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:8000,suspend=y</option>
                        </options>
                        <mainClass>org.waninge.test.JFXTest</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>

在IntelliJ中使用命令行"中的"javafx:run @ debug"创建Maven运行配置. 使用以下设置创建远程运行配置:

Create a Maven Run Configuration in IntelliJ with 'javafx:run@debug' in the 'Command line'. Create a Remote Run Configuration with the following settings:

  • 调试器模式:侦听远程JVM";
  • 运输:套接字";
  • 主持人:与pom中一样
  • 端口:如pom中一样

现在,远程运行配置"将启动调试服务器,以等待客户端. Maven运行配置将连接到调试服务器,如果调试服务器不在线,则失败.

Now the Remote Run Configuration will start a debug server waiting for clients. The Maven Run Configuration will connect to the debug server, or fail if the debug server isn't online.

现在,只需单击一下就可以开始一切,您可以创建一个复合运行配置并向其中添加Maven和远程运行配置.启动此配置将并行启动两者,您可以调试应用程序.

Now, to get everything started with a single click, you can create a Compound Run Configuration and add the Maven and the Remote Run Configuration to it. Starting this configuration will launch the two in parallel, and you can debug your application.

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

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