gpt4 book ai didi

java - SparkJava 异常 java.lang.NoClassDefFoundError : org/eclipse/jetty/websocket/server/pathmap/PathSpec

转载 作者:行者123 更新时间:2023-11-29 04:40:40 24 4
gpt4 key购买 nike

对于带有代码的Spark-java(与Spring Boot一起使用)

public static void main(String[] args) {
Spark.port(8080);
Spark.webSocket("/chat", ChatWebSocketHandler.class);
Spark.init();

我得到异常并停止

Exception in thread "Thread-2" java.lang.NoClassDefFoundError: org/eclipse/jetty/websocket/server/pathmap/PathSpec
at spark.embeddedserver.jetty.EmbeddedJettyServer.ignite(EmbeddedJettyServer.java:105)
at spark.Service.lambda$init$0(Service.java:349)
at spark.Service$$Lambda$7/1663488386.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.websocket.server.pathmap.PathSpec
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more

我用的是Maven

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>


<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.5</version>
</dependency>

我明白了jetty-server-9.3.11.v20160721.jar,websocket-server-9.3.11.v20160721.jar 和许多其他依赖项

在演示中同样有效 https://github.com/tipsy/spark-websocket

最佳答案

问题是 Spring Boot 重新定义了要使用的更新的 Jetty 版本。

解决者

<properties>
...
<jetty.version>9.3.6.v20151106</jetty.version> <!-- redefine for sparkjava 2.5 vs 9.3.11.v20160721 in spring-boot-dependencies -->
</properties>

关于java - SparkJava 异常 java.lang.NoClassDefFoundError : org/eclipse/jetty/websocket/server/pathmap/PathSpec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39323372/

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