You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac环境下JavaFX项目运行报错:找不到bingespice_app模块

macOS下JavaFX模块找不到问题排查

错误信息

Error occurred during initialization of boot layer
java.lang.module.FindException: Module bingespice_app not found

Process finished with exit code 

背景信息

  • 团队成员均使用Windows系统,仅本人使用macOS
  • 初始环境JavaFX 17+JDK 22运行失败,更换为JavaFX 24+JDK 23后出现上述模块找不到错误
  • 已尝试调整VM选项、移动module-info.java位置、修改模块名称大小写(原名称Bingespice_App),问题未解决

关键配置文件

module-info.java

module bingespice_app {
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.web;

    requires org.controlsfx.controls;
    requires com.dlsc.formsfx;
    requires net.synedra.validatorfx;
    requires org.kordamp.ikonli.javafx;
    requires org.kordamp.bootstrapfx.core;
    requires eu.hansolo.tilesfx;
    requires com.almasb.fxgl.all;
    requires java.desktop;

    opens com.example.bingespice_app to javafx.fxml;
    exports com.example.bingespice_app;
}

pom.xml核心问题片段

<!-- JavaFX依赖版本与本地环境不匹配 -->
<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>17.0.6</version> <!-- 本地用JavaFX24,此处版本不一致 -->
    </dependency>
    <!-- 其他JavaFX依赖均为17.0.6版本 -->
</dependencies>

<build>
    <plugins>
        <!-- mainClass模块名大小写与module-info不匹配 -->
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.8</version>
            <executions>
                <execution>
                    <configuration>
                        <mainClass>com.example.bingeSpice_app/com.example.bingeSpice_app.Main</mainClass>
                        <!-- 模块名bingeSpice_app与module-info中的bingespice_app大小写不一致 -->
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

问题根源及修复步骤

  1. 大小写不匹配(macOS大小写敏感)
    macOS对文件名、模块名大小写敏感,Windows则不敏感。pom.xml中javafx-maven-plugin的mainClass配置里模块名是bingeSpice_app,但module-info.java定义的模块名是bingespice_app,导致系统无法识别模块。

    • 修复:将mainClass改为com.example.bingespice_app/com.example.bingespice_app.Main,确保与module-info.java的模块名完全一致。
  2. JavaFX版本不一致
    本地使用JavaFX 24,但pom.xml中所有JavaFX依赖版本为17.0.6,版本不兼容会引发模块加载异常。

    • 修复:将pom.xml中所有JavaFX依赖的版本统一改为24,与本地环境保持一致。
  3. Maven编译插件适配JDK23
    当前maven-compiler-plugin版本3.13.0与JDK23存在兼容性风险,建议升级至最新稳定版(如3.14.0)。

验证操作

  • 执行mvn clean install清理并重新构建项目
  • 用mvn javafx:run启动应用,或在IDE中更新Maven配置后运行

内容的提问来源于stack exchange,提问作者AndreasKaram

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 09:22:15