简体   繁体   English

javafx.controls 无法解析为模块信息中的模块。java

[英]javafx.controls cannot be resolved to a module in module-info.java

Actual state实际 state

I am learning JavaFx and trying to make a reusable component.我正在学习 JavaFx 并尝试制作一个可重用的组件。 The project is being developed in VSCode.该项目正在 VSCode 中开发。 The project is very simple and deals with a launcher and the reusable component.该项目非常简单,涉及启动器和可重用组件。 I was refactoring and when adding the modules everything has stopped working and I can't continue with the refactoring.我正在重构,当添加模块时,一切都停止了,我无法继续重构。

Issue问题

The error displayed inside the module-info is: javafx.controls cannot be resolved to a module . module-info 中显示的错误是: javafx.controls cannot be resolved to a module though oddly enough, if I tell Maven to update the project, on some rare occasion the error changes to tell me that the module is empty or doesn't exist.虽然奇怪的是,如果我告诉 Maven 更新项目,在极少数情况下,错误会更改为告诉我模块为空或不存在。

Source code源代码

The source code ( experimental branch): https://github.com/Osolemio44/text-area-right This is the structure of the project:源码(实验分支): https://github.com/Osolemio44/text-area-right这是项目的结构:

C:\WORKSPACE\TEXT-AREA-RIGHT
├───.vscode
├───src
│   └───main
│       ├───java
│       │   └───com
│       │       └───adeso
│       │           ├───custom
│       │           └───launcher
│       └───resources
│           └───com
│               └───adeso
└───target

Module-info of the launcher:启动器的模块信息:

module com.adeso.launcher {

    requires transitive javafx.controls;
    requires javafx.fxml;

    opens com.adeso.launcher to javafx.fxml;

    exports com.adeso.launcher;
}

Module-info of the component:组件的模块信息:

module com.adeso.custom {

    requires transitive javafx.controls;
    requires javafx.fxml;

    opens com.adeso.custom to javafx.fxml;

    // exports com.adeso.custom;
}

Pom.xml Pom.xml

<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>com.adeso</groupId>
    <artifactId>text-area-right</artifactId>
    <version>0.0.1</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17.0.2</maven.compiler.source>
        <maven.compiler.target>17.0.2</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>17.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>17.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.9.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <!--  ============================================
              ============================================
              =                 PLUGINS                  =  
              ============================================
              ============================================  -->


        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.8</version>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                        <configuration>
                            <mainClass>com.adeso.launcher.App</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--  +++++++++++++++++++++++++
                  +          JUNIT        +
                  +++++++++++++++++++++++++ -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M7</version>
            </plugin>
        </plugins>
    </build>
</project>

After checking all the info of jewelsea, i changed the structure of my project and now it seems to work.在检查了jewelsea的所有信息后,我改变了我的项目结构,现在它似乎可以工作了。 I changed to a Maven modules project and created 1 module-info.java inside each maven module.我更改为 Maven 模块项目并在每个 maven 模块内创建了 1 个模块信息。java。

C:\WORKSPACE\TEXT-AREA-RIGHT
├───.vscode
├───launchermodule
│   └───src
│       └───main
│           ├───java
│           │   └───com
│           │       └───adeso
│           │           └───custom
│           └───resources
│               └───com
│                   └───adeso
│                       └───custom
└───nodemodule
    └───src
        ├───main
        │   ├───java
        │   │   └───com
        │   │       └───adeso
        │   │           └───custom
        │   └───resources
        │       └───com
        │           └───adeso
        │               └───custom
        └───test
            └───java
                └───com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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