我正在Intellij下使用Maven编写我的第一个JavaFX v17.0项目。一切都很好,我能够创建一个JavaFX视图控制器并显示它。但是当我将这些行添加到模块信息时,问题来了:
requires Rserve;
requires REngine;
它对应于pom.xml中的那些依赖项:
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/Rserve -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>Rserve</artifactId>
<version>1.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/REngine -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>REngine</artifactId>
<version>2.1.0</version>
</dependency>
当我编译时,我得到这些错误:
...
Checking sources
Copying resources... [first-javafx-try]
Parsing java... [first-javafx-try]
java: the unnamed module reads package java.io from both api.classic and java.base
java: the unnamed module reads package java.lang from both api.classic and java.base
java: module api.classic reads package java.lang from both java.base and api.classic
java: module api.classic reads package java.io from both java.base and api.classic
java: module REngine reads package java.lang from both java.base and api.classic
java: module REngine reads package java.io from both java.base and api.classic
java: module Rserve reads package java.lang from both java.base and api.classic
java: module Rserve reads package java.io from both java.base and api.classic
Checking dependencies... [first-javafx-try]
...
我试着将这些行添加到vm配置中:
--add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.base/java.io=ALL-UNNAMED
但还是不行。
你能解释一下错误的来源和解决方法吗?
更新
事实上,RServe和REngine的依赖关系并没有模块化,但我不知道如何处理。
要了解更多信息,请查看完整的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0-SNAPSHOT</version>
<name>demo</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.7.1</junit.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/Rserve -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>Rserve</artifactId>
<version>1.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.rosuda.REngine/REngine -->
<dependency>
<groupId>org.rosuda.REngine</groupId>
<artifactId>REngine</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17-ea+11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17-ea+11</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.1.0</version>
</dependency>
<dependency>
<groupId>com.dlsc.formsfx</groupId>
<artifactId>formsfx-core</artifactId>
<version>11.3.2</version>
<exclusions>
<exclusion>
<groupId>org.openjfx</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.kordamp.bootstrapfx</groupId>
<artifactId>bootstrapfx-core</artifactId>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.demo/root.circlepong.CirclePongApp</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
模块信息:
module root {
requires javafx.controls;
requires javafx.fxml;
requires Rserve;
requires REngine;
opens root.circlepong to javafx.fxml;
exports root.circlepong;
opens root.switchscene to javafx.fxml;
exports root.switchscene;
opens root.mvvmfxFirsttry to javafx.fxml;
exports root.mvvmfxFirsttry;
}
更新2
当运行compile命令时,我发现Intellij运行命令:
C:\Users\Thibault\.jdks\openjdk-17.0.1\bin\java.exe "-javaagent:D:\IntelliJ IDEA 2021.2.2\lib\idea_rt.jar=52247:D:\IntelliJ IDEA 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\Programmation\MASI1.5\CarteAPuce\JavaCardsTools\lib\api_classic-3.1.0.jar;D:\JavaProg\MASI_Projet_Integre\mavenJava11Project\target\classes;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx-swt.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.web.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.base.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.fxml.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.media.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.swing.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.controls.jar;C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib\javafx.graphics.jar;C:\Users\Thibault\.m2\repository\org\rosuda\REngine\Rserve\1.8.1\Rserve-1.8.1.jar;C:\Users\Thibault\.m2\repository\org\rosuda\REngine\REngine\2.1.0\REngine-2.1.0.jar" root.switchscene.SwitchSceneApp --module-path C:\Program Files\JavaFX\javafx-sdk-17.0.6\lib --add-modules javafx.controls,javafx.fxml
这里我们可以看到类路径中有一个jar 'api_classic-3.1.0.jar',但是我从来没有指定它,我如何从自动命令中删除它?
1条答案
按热度按时间ykejflvf1#
我发现问题来自'D:\Programmation\MASI1.5\CarteAPuce\JavaCardsTools\lib\api_classic-3.1.0.jar'添加的jar。由于我无法从Intellij自动命令中删除该行,我删除了jar,现在一切正常。这可能不是最好的方法,但它有效。