缺少 JavaFX 运行时组件,即使我的 VM 选项和模块中已经有了它们

JavaFX runtime components are missing, even though I already have them in my VM options and Modules

我收到这个错误:

Error: JavaFX runtime components are missing, and are required to run this application

Process finished with exit code 1

我在 YouTube 和 Whosebug 上查看了多个解决方案,例如 https://www.youtube.com/watch?v=KKI7tDozPog and Error: JavaFX runtime components are missing, and are required to run this application with JDK 11

因此,我听从了他们的建议,并将他们所说的添加到我的 VM 选项中。这就是我的 运行 配置

尽管如此,我还是遇到了这个错误。

这是我的一些代码:

我的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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>proj4</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>proj4</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.7.1</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17-ea+11</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17-ea+11</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.1</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running with: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>com.example.proj4/application.proj4.PizzeriaApplication</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我的申请

package application.proj4;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;

public class PizzeriaApplication extends Application
{
    /**
     * This method is the start of the application.
     * @param stage A Stage object
     * @throws IOException An IOException object
     */
    @Override
    public void start(Stage stage) throws IOException
    {
        FXMLLoader fxmlLoader = new FXMLLoader(PizzeriaApplication.class.getResource("pizzeria-view.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 800, 600);
        stage.setTitle("RU Pizzeria");
        stage.setResizable(false);
        stage.setScene(scene);
        stage.show();

        //This closes the entire application if the Main Menu window is closed
        stage.setOnCloseRequest(t ->
        {
            Platform.exit();
            System.exit(0);
        });
    }

    /**
     * This method launches the application.
     * @param args An array of Strings
     */
    public static void main(String[] args)
    {
        launch();
    }
}

我在项目结构模块中的依赖项

欢迎回复。

好的,我知道为什么会这样了。

我把模块路径和添加模块放在程序参数中,而不是在 vm 选项中,这是导致红色问题的原因。

现在我遇到了“引导层初始化期间发生错误”的问题。