![](/img/trans.png)
[英]JavaFX module-info error the unnamed module reads package javax.validation from both java.validation and jakarta.jakartaee.api
[英]The unnamed module reads package javax.websocket from both
當我需要 org.eclipse.jetty.server 並將其導入我的 class 時出現錯誤。 import org.eclipse.jetty.server.Server;
.
The unnamed module reads package javax.websocket from both javax.websocket.api and javax.websocket.client.api. 我嘗試在我的 pom.xml 中刪除依賴項。 這也行不通。
我的項目中共有 3 個模塊: - seabattleclient - seabattleserver - seabattlelogin
下面是我的項目結構: https://imgur.com/a/YMFNbwu
我服務器上的 pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>SeaBattleStart</artifactId>
<groupId>nl.fhict.s3</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>seabattleserver</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.4.15.v20190215</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>
</project>
我的登錄中的 pom 文件
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>SeaBattleStart</artifactId>
<groupId>nl.fhict.s3</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>SeaBattleLogin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
</dependencies>
</project>
我客戶的 pom 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>SeaBattleStart</artifactId>
<groupId>nl.fhict.s3</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<openfxVersion>11.0.2</openfxVersion>
<junit-jupiter-api.version>5.3.2</junit-jupiter-api.version>
<logback-classic.version>1.2.3</logback-classic.version>
</properties>
<artifactId>seabattleclient</artifactId>
<dependencies>
<!-- (open)Java FX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${openfxVersion}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${openfxVersion}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${openfxVersion}</version>
</dependency>
<!-- Logback -->
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic.version}</version>
</dependency>
<!-- JUnit 5 -->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.fhict.s3</groupId>
<artifactId>SeaBattleLogin</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies></project>
我的模塊信息.java
module seabattleserver {
requires org.eclipse.jetty.server;
}
如果我刪除了要求,我將無法使用我的項目所需的東西。 所以我需要另一個解決方案。
您可以只排除 javax.websocket-client-api。
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.4.15.v20190215</version>
<exclusions>
<exclusion>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-client-api</artifactId>
</exclusion>
</exclusions>
</dependency>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.