java - 模块“项目”从“javafx.base”和“javafx.base”读取包“javafx.beans”
问题描述
标题中的错误是我的 module-info.java 中的错误。我是Java新手,所以我希望你给出答案时我能理解你的答案。我在这里找到了提出相同问题的其他问题,他们可能有答案,我只是不明白如何将其应用于我的情况。
模块化java项目(IntelliJ IDEA):模块“com.test”从“java.xml.bind”和“java.xml.bind”读取包“javax.xml.bind”
包“com.example”从“javafx.base”和“javafx.base”中读取包“javafx.beans”
这是该文件的样子:
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>
模块信息.java
module demo.hello {
requires javafx.controls;
requires javafx.fxml;
exports demo.hello;
}
推荐阅读
- batch-file - 使用批处理文件创建 GPO 以部署 msi
- javascript - IIFE 语法最佳实践
- javascript - 关于导入js模块和函数作用域(local/global)的问题
- bash - Grep 排除某些序列
- google-chrome - chrome中requestfullscreen和getDisplayMedia的交互
- javascript - JavaScript正则表达式删除数字逗号数字中的逗号
- reactjs - npm 错误!在 '..."eslint":"^3.15.0","e' 附近解析时 JSON 输入意外结束
- javascript - 如何在可以在 Dialogflow 中多次调用 agent.add 的函数中添加循环?
- python - TFX - REST API,无需序列化数据输入以获取预测
- racket - 为什么我会收到“arity mismatch”错误?SICP中的练习1.43