简体   繁体   中英

intellij idea : how to debug a java:fx maven project?

I have a old javafx application that I have to run by doing mvn javafx:run but now I would like to debug it with intellij idea.

If I debug the configuration I use to run it, the debugger is connected but it doesn't stop at any breakpoint.

If I try to run a mvn command like mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=6666" javafx:run and connect with the remote I get this error (from the debugger):

java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector: Provider

sun.jvm.hotspot.jdi.SACoreAttachingConnector not found java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector: Provider

sun.jvm.hotspot.jdi.SADebugServerAttachingConnector not found java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector: Provider

sun.jvm.hotspot.jdi.SAPIDAttachingConnector not found

sa-jdwp server connected

I am not sure what I need to do to be able to debug it.

The pom.xml:

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
     http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>ProjectId</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <!-- necessary for intellij to function -->
    <maven.compiler.source>1.11</maven.compiler.source>
    <maven.compiler.target>1.11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.10</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>14-ea+7</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>14-ea+7</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>14-ea+7</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>14-ea+7</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.4.0-b180830.0359</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>2.3.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.4.0-b180830.0438</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.7.6-RC2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.3</version>
            <configuration>
                <mainClass>project.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

</project>

I found a way to make debugging work by creating a debug execution in the pom.xml and then using intellij idea to remote debug it.

I so now I can run: mvn clean javafx:run@debug

The new build of my pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.3</version>
            <executions>
                <execution>
                    <id>run</id>
                    <configuration>
                        <mainClass>project.Main</mainClass>
                    </configuration>
                </execution>
                <execution>
                    <id>debug</id>
                    <configuration>
                        <mainClass>project.Main</mainClass>
                        <options>
                            <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000</option>
                        </options>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM