运行 最新的 Jetty 版本破坏了我的构建

Running the latest Jetty version breaks my build

我在我的 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 是不稳定的 in-development 版本。它还没有准备好用于一般用途。准备就绪后,确实需要 Java 的更新版本,可能还需要其他支持软件的更新版本。这是主要版本跳转的典型情况。

根据https://www.eclipse.org/jetty/download.html,适合一般使用的最新稳定版 Jetty 是 9.4.19.v20190610。这就是你应该使用的。它将与 OpenJDK 1.8 一起使用,就像 9.4.18 一样。