无法添加javafx.web到Maven项目在VS Code



我是maven和java项目的新手,我一直在尝试添加javafx。web到我的Maven项目,特别是htmlitor类,在VS Code上,到目前为止还无法。

我已经将依赖项添加到pom.xml文件中,并放入导致我安装JavaFX的VM参数,但没有任何工作。

是否有一种方法可以做到这一点,我错过了,或者只是以某种方式直接添加JavaFX JavaFX -sdklib文件夹中的JavaFX .web.jar的副本会更好?

我的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>dylan.gresham</groupId>
<artifactId>nottah</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<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>19</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>19</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.8</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>dylan.gresham.Main</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>dylan.gresham.Driver</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

My VM Arguments:

--module-path C:UsersdylanDownloadsJavaFXjavafx-sdk-18.0.1lib --add-modules =ALL -MODULE-PATH

我module-info.java:

module dylan.gresham {
requires javafx.controls;
requires javafx.fxml;
requires transitive javafx.graphics;
opens dylan.gresham to javafx.fxml;
exports dylan.gresham;
}

编辑:增加了上面的module-info文件。

正如@James_D所指出的,我需要将requires javafx.web;添加到我的module-info.java文件中。添加了这一行之后,我就可以导入所需的内容了。

相关内容

  • 没有找到相关文章

最新更新