Spring boot 1.5.8.RELEASE imports Java 8 compiled class

Spring boot 1.5.8.RELEASE imports Java 8 compiled class

我不知道我是否遗漏了什么,但我有一个 Java 7,spring-boot 项目,我试图在其中导入和使用 htmlunit。 Htmlunit 使用 org/eclipse/jetty/websocket/api/Session 我得到

java.lang.UnsupportedClassVersionError: org/eclipse/jetty/websocket/api/Session : Unsupported major.minor version 52.0

运行 mvn dependency:tree 我可以获取 websocket 版本:

[INFO] |  +- net.sourceforge.htmlunit:htmlunit:jar:2.21:compile
[INFO] |  |  +- xalan:xalan:jar:2.5.1:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
[INFO] |  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.8:compile
[INFO] |  |  +- org.apache.httpcomponents:httpmime:jar:4.5.3:compile
[INFO] |  |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:compile
[INFO] |  |  +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] |  |  |  \- xerces:xercesImpl:jar:2.8.1:provided
[INFO] |  |  |     \- xml-apis:xml-apis:jar:1.4.01:provided
[INFO] |  |  +- net.sourceforge.cssparser:cssparser:jar:0.9.18:compile
[INFO] |  |  |  \- org.w3c.css:sac:jar:1.3:compile
[INFO] |  |  \- org.eclipse.jetty.websocket:websocket-client:jar:9.4.7.v20170914:compile
[INFO] |  |     +- org.eclipse.jetty:jetty-client:jar:9.4.7.v20170914:compile
[INFO] |  |     |  \- org.eclipse.jetty:jetty-http:jar:9.4.7.v20170914:compile
[INFO] |  |     +- org.eclipse.jetty:jetty-xml:jar:9.4.7.v20170914:compile
[INFO] |  |     +- org.eclipse.jetty:jetty-util:jar:9.4.7.v20170914:compile
[INFO] |  |     +- org.eclipse.jetty:jetty-io:jar:9.4.7.v20170914:compile
[INFO] |  |     \- org.eclipse.jetty.websocket:websocket-common:jar:9.4.7.v20170914:compile
[INFO] |  |        \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.7.v20170914:compile

确实是在 spring-boot https://github.com/spring-projects/spring-boot/issues/10396

的 1.5.8.RELEASE 上升级

所以..我错过了什么吗? spring boot 1.5.8 Java 7 兼容吗?

编辑:https://github.com/eclipse/jetty.project/issues/2151 那么...我应该降级我的 spring-boot 版本吗?我还不能超过 Java 7。

这里有两个不同的地方:Spring Boot 1。5.x 本身需要 JDK7+,但这个要求可能会根据您选择的容器而改变。

Jetty 9.3+ 需要 JDK8,但使用 Jetty 9.2 和 JDK7 应该没问题(参见 Spring Boot 1.5.x system requirements page)。

通过更改 <jetty.version> maven 属性 来降低对码头的依赖性就足够了。

Spring 引导构建示例应用程序以演示兼容性 - here's one for Spring Boot 1.5.x + Jetty 9.2