模块 'project' 从'javafx.base'和'javafx.base'读取包'javafx.beans'



标题中的错误是我的模块-info.java中的错误。我是java新手,所以我希望在你给出答案时能理解你的答案。我发现这里的其他问题也提出了同样的问题,他们可能已经找到了答案,我只是不知道如何将其应用于我的情况。

javafx.base读取包javafx.beans

模块化java项目(IntelliJ IDEA(:模块';com.test';读取包';javax.xml.bind';从两者';java.xml.bind';和';java.xml.bind';

软件包';com.example';读取包';javafx.beans';从两者';javafx.base';和';javafx.base';

以下是该文件的样子:

module project{
requires javafx.controls;
requires javafx.fxml;
requires sikulixapi;
opens com.example to javafx.fxml;
exports com.example;
}

当我注释掉javafx.*的两个require行时,错误就消失了。

我正在使用Intellij Idea,我创建了一个Javafx项目并添加了Maven。

我该如何着手找到这个问题的解决方案?

我认为这是一个Intellj问题。我在Eclipse中创建了Hello World JavaFX示例,没有遇到任何问题。

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>demo</groupId>
<artifactId>hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml </artifactId>
<version>17-ea+14</version>
</dependency>
</dependencies>
<build>
<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.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>demo.hello.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

fo.java 模块

module demo.hello {
requires javafx.controls;
requires javafx.fxml;
exports demo.hello;
}

最新更新