为什么 Maven javafx 插件无法 运行 测试项目

Why is the Maven javafx plugin failing to run the test project

我正在尝试按照本教程在 IntelliJ https://openjfx.io/openjfx-docs/#maven(IntelliJ 非模块化与 Maven)中设置 Maven JavaFX 项目,但无论我做什么都失败了。

我尝试了很多互联网建议。我尝试在 pom 中设置 VM 变量,确保 JAVA_HOME 指向我的 JDK 12 目录,并且我检查了项目结构中的 JDK 是否正确设置。

这是我的 pom 文件:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>asterion</groupId>
    <artifactId>exitpoll</artifactId>
    <packaging>jar</packaging>
    <version>0.1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>12.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>12.0.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>12</source>
                    <target>12</target>
                    <release>12</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.3</version>
                <configuration>
                    <source>12</source>
                    <target>12</target>
                    <release>12</release>
                    <mainClass>asterion.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是输出:

"C:\Program Files\Java\jdk-12.0.2\bin\java.exe" -Dmaven.multiModuleProjectDirectory=D:\exitpoll "-Dmaven.home=L:\software\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=L:\software\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=L:\software\IntelliJ IDEA 2019.2\plugins\maven\lib\maven-event-listener.jar" "-javaagent:L:\software\IntelliJ IDEA 2019.2\lib\idea_rt.jar=61323:L:\software\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath "L:\software\IntelliJ IDEA 2019.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2019.2.1 org.openjfx:javafx-maven-plugin:0.0.3:run
[IJ]-1-Unknown-[IJ]-event=org.apache.maven.settings.building.DefaultSettingsBuildingRequest@1bdf8190
[IJ]-1-Unknown-[IJ]-event=org.apache.maven.settings.building.DefaultSettingsBuildingResult@50687efb
[IJ]-1-Unknown-[IJ]-event=org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest@56e07a08
[IJ]-1-ProjectDiscoveryStarted-[IJ]-id=unknown
[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------------< asterion:exitpoll >--------------------------
[INFO] Building exitpoll 0.1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[IJ]-1-ARTIFACT_RESOLVED-[INFO] 
[INFO] --- javafx-maven-plugin:0.0.3:run (default-cli) @ exitpoll ---
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.apache:apache:pom:21-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\apache\apache\apache-21.pom-[IJ]-artifactCoord=org.apache:apache:pom:21-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.eclipse.sisu:org.eclipse.sisu.plexus:pom:0.3.3-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\jboss\weld\weld-api-parent.0\weld-api-parent-1.0.pom-[IJ]-artifactCoord=org.jboss.weld:weld-api-parent:pom:1.0-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.codehaus.plexus:plexus-languages:pom:0.9.11-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.ow2.asm:asm:pom:7.0-beta-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\com\thoughtworks\qdox\qdox.0-M9\qdox-2.0-M9.pom-[IJ]-artifactCoord=com.thoughtworks.qdox:qdox:pom:2.0-M9-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\apache\commons\commons-parent\commons-parent-43.pom-[IJ]-artifactCoord=org.apache.commons:commons-parent:pom:43-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\codehaus\plexus\plexus-utils.5.5\plexus-utils-1.5.5.pom-[IJ]-artifactCoord=org.codehaus.plexus:plexus-utils:pom:1.5.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.apache.maven:maven-model-builder:pom:3.0.5-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\codehaus\plexus\plexus.1\plexus-5.1.pom-[IJ]-artifactCoord=org.codehaus.plexus:plexus:pom:5.1-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\apache\commons\commons-parent\commons-parent-39.pom-[IJ]-artifactCoord=org.apache.commons:commons-parent:pom:39-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVING-[IJ]-path=-[IJ]-artifactCoord=org.apache:apache:pom:16-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\codehaus\mojo\mojo-parent\mojo-parent-34.pom-[IJ]-artifactCoord=org.codehaus.mojo:mojo-parent:pom:34-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\org\codehaus\plexus\plexus-utils.1.0\plexus-utils-3.1.0.jar-[IJ]-artifactCoord=org.codehaus.plexus:plexus-utils:jar:3.1.0-[IJ]-error=
[IJ]-1-ARTIFACT_RESOLVED-[IJ]-path=C:\Users\***\.m2\repository\com\google\code\findbugs\jsr305.0.2\jsr305-3.0.2.jar-[IJ]-artifactCoord=com.google.code.findbugs:jsr305:jar:3.0.2-[IJ]-error=
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\***\.m2\repository\org\openjfx\javafx-base.0.2\javafx-base-12.0.2-win.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 55.0
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:491)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:453)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:491)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:453)
    at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.009 s
[INFO] Finished at: 2019-08-25T22:03:42+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:run (default-cli) on project exitpoll: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


[INFO] 
[INFO] -------------------------< asterion:exitpoll >--------------------------
[INFO] Building exitpoll 0.1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- javafx-maven-plugin:0.0.3:run (default-cli) @ exitpoll ---
Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\***\.m2\repository\org\openjfx\javafx-base.0.2\javafx-base-12.0.2-win.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 55.0
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:491)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:453)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:491)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:453)
    at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:97)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

正如 José Pereda 指出的那样,重要的错误信息是 java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 55.0

我解决了它,尽管是以一种有点激进的方式。由于某种原因,java -version 返回了一个不同的 Java 版本,10。我从我的计算机中删除了所有 JDK 并重新安装了 JDK 12,现在问题解决了。 感谢 José Pereda 帮助查明问题!