gpt4 book ai didi

java - 未命名的模块从两者读取包javax.websocket

转载 作者:行者123 更新时间:2023-12-01 22:10:17 27 4
gpt4 key购买 nike

当我需要org.eclipse.jetty.server并将其导入到我的班级时,我得到一个错误。
import org.eclipse.jetty.server.Server;

未命名的模块从javax.websocket.api和javax.websocket.client.api都读取包javax.websocket。我尝试删除pom.xml中的依赖项。这也不起作用。

我的项目中总共有3个模块:
-seabattleclient
-海上战斗机
-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>


我的module-info.java

module seabattleserver {
requires org.eclipse.jetty.server;
}


如果删除需求,则无法使用项目所需的东西。所以我需要另一个解决方案。

最佳答案

This question pretty much covers this problem.

您可以只排除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>

关于java - 未命名的模块从两者读取包javax.websocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58665110/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com