我在我的 java 项目中使用 Jetty。我使用 gradle 来构建和 OpenJDK 1.8。
最近我的构建失败了,我确定如果我回滚 Jetty 版本就可以修复。看起来新版本的 Jetty jar 是用不同版本的 Java 构建的(我只是在这里猜测)。
这是我的 build.gradle...
apply plugin: 'java'
// Use maven repository
repositories {
mavenCentral()
}
dependencies {
implementation 'org.eclipse.jetty:jetty-servlet:+'
implementation 'org.eclipse.jetty:jetty-client:+'
}
这是构建错误...
/home/me/src/Chess/src/main/java/Client.java:1: error: cannot access HttpClient import org.eclipse.jetty.client.HttpClient; ^ bad class file: /home/me/.gradle/caches/modules-2/files-2.1/org.eclipse.jetty/jetty-client/10.0.0-alpha0/81ce90a421540f2c7e4e3026702dde608fc95c83/jetty-client-10.0.0-alpha0.jar(org/eclipse/jetty/client/HttpClient.class) class file has wrong version 55.0, should be 52.0 Please remove or make sure it appears in the correct subdirectory of the classpath.
当我更改 gradle.build 以使用以前版本的 Jetty 时,构建可以正确编译...
dependencies {
implementation 'org.eclipse.jetty:jetty-servlet:9.4.18.v20190429'
implementation 'org.eclipse.jetty:jetty-client:9.4.18.v20190429'
}
如何在不破坏构建的情况下使用最新版本的 Jetty?我必须升级 Java 版本吗?这似乎不是一个好的解决方案......
最佳答案
Jetty 10 是不稳定的、正在开发的版本。它尚未准备好用于一般用途。当它准备就绪时,它确实需要更新版本的 Java 以及可能更新版本的其他支持软件。这是主要版本跳转的典型情况。
适合一般用途的Jetty最新稳定版本,据https://www.eclipse.org/jetty/download.html ,是 9.4.19.v20190610。这就是你应该使用的。它会很高兴使用 OpenJDK 1.8,就像 9.4.18 一样。
关于java - 运行最新的 Jetty 版本会破坏我的构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57022982/