从JavaFX项目引用外部JAR



我试图从我的JavaFX项目中引用一组api:

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;

这些api在此依赖项中可用:

<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.0.0</version>
</dependency>

因此,我添加了jakarta.ws. .Rs-api在我的项目的模块-info.java:

module com.example.javafx {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
//External API
requires jakarta.ws.rs-api;
opens com.example.javafx to javafx.fxml;
exports com.example.javafx;
}

然而,它似乎是不正确的:"Module directive expected"为"jakarta.ws.rs-api"我应该使用不同的格式来指定外部依赖关系吗?由于

必须在requires之后使用模块名。模块名不允许使用破折号,就像包名一样。

您可以使用以下命令获取绑定在jar文件中的模块名称:

jar --describe-module --file jakarta.ws.rs-api-3.1.0.jar

得到jakarta.ws.rs

最新更新