我的JavaFX应用程序(Java 21,OpenJFX 21)无法识别依赖项,我不知道为什么. 该依赖项被列为我的pom的依赖项中的第一个条目.

EDIT: the dependency org.mrpc.CommonUtilities is something I wrote and is in my local repository.

我的pom.xml文件是:

<dependencies>
    <dependency>
        <groupId>org.mrpc</groupId>
        <artifactId>CommonUtilities</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>21</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>21</version>
    </dependency>
    <dependency>
        <groupId>org.controlsfx</groupId>
        <artifactId>controlsfx</artifactId>
        <version>11.1.2</version>
    </dependency>
    <dependency>
        <groupId>com.dlsc.formsfx</groupId>
        <artifactId>formsfx-core</artifactId>
        <version>11.6.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.synedra</groupId>
        <artifactId>validatorfx</artifactId>
        <version>0.4.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.kordamp.ikonli</groupId>
        <artifactId>ikonli-javafx</artifactId>
        <version>12.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.kordamp.bootstrapfx</groupId>
        <artifactId>bootstrapfx-core</artifactId>
        <version>0.4.0</version>
    </dependency>

我的MODULE-INFO.Java文件是(我的依赖项的类路径是org.mrpc实用程序):

module org.sperbolink.monthlyfinances {
    requires javafx.controls;
    requires javafx.fxml;

    requires org.controlsfx.controls;
    requires com.dlsc.formsfx;
    requires net.synedra.validatorfx;
    requires org.kordamp.ikonli.javafx;
    requires org.kordamp.bootstrapfx.core;
    requires org.mrpc.utilities;

    opens org.sperbolink.monthlyfinances to javafx.fxml;
    exports org.sperbolink.monthlyfinances;
}

maven dependency:tree显示:

[INFO] org.sperbolink:MonthlyFinances:jar:1.0-SNAPSHOT
[INFO] +- org.mrpc:CommonUtilities:jar:1.0-SNAPSHOT:compile
[INFO] +- org.openjfx:javafx-controls:jar:21:compile
[INFO] |  +- org.openjfx:javafx-controls:jar:win:21:compile
[INFO] |  \- org.openjfx:javafx-graphics:jar:21:compile
[INFO] |     +- org.openjfx:javafx-graphics:jar:win:21:compile
[INFO] |     \- org.openjfx:javafx-base:jar:21:compile
[INFO] |        \- org.openjfx:javafx-base:jar:win:21:compile

而来自Maven的错误是:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project MonthlyFinances: Compilation failure
[ERROR] /D:/NonGitRepo/MonthlyFinances/src/main/java/module-info.java:[10,22] module not found: org.mrpc.utilities

推荐答案

错误消息告诉您错误:

module not found: org.mrpc.utilities

您的模块路径上没有名为org.mrpc.utilities的模块.

当您需要项目module-info.java中的模块时,它需要是位于模块路径上的有效模块.

您编写的包含在依赖项构件CommonUtilities中的模块的java模块名(不是包名、JAR名或maven构件名)是什么?

有三个选项:

  1. 它将出现在您编写CommonUtilities JAR中包含的模块时创建的module-info.java中.
  2. 如果没有模块信息,则模块名称将出现在CommonUtilities JAR的META-INF中的Automatic-Module-Name中.
  3. 如果META-INF中没有定义自动名称,则分配的自动模块名称为CommonUtilities,与JAR名称相同.

要了解更多信息,请参阅:

通常,如果您希望将您创建的软件视为完整模块而不是自动模块,则向该软件提供适当的module-info.java来命名该模块,并在您需要或以其他方式使用该模块时使用相同的模块名称.

Java相关问答推荐

如何为具有多对多关系的实体的给定SQL查询构建JPA规范?

将linkedHashMap扩展到Java中的POJO类

BiPredicate和如何使用它

SQlite for Android无法使用json_group_array/json_object

S的字符串表示是双重精确的吗?

给定Java枚举类,通过值查找枚举

为什么Java Annotation接口覆盖对象类中的方法

由于 list 中的权限错误,Android未生成

我的Spring Boot测试显示&IlLegalStateException:无法加载某事的ApplicationContext.

try 将JSON字符串响应从API转换为映射字符串、对象>;时出错

是否为计划任务补偿系统睡眠?

将ByteBuffer异步写入InputStream或Channel或类似对象

将关闭拍卖的TimerService

Dijkstra搜索算法的实现

在Oracle中调用输出参数在索引处缺少IN或OUT参数的函数

如何修复Spring Boot应用程序中的RestDocumentationGenerationException:java.io.FileNotFoundException:/curl-request.adoc(只读文件系统)?

rest api服务 spring 启动中出现IllegalFormatConversionException

谷歌应用引擎本地服务器赢得';t在eclipse上运行

在输入端没有可行的替代方案'; Select *';

@此处不能应用可为null的批注