【问题标题】:Spring boot 1.5.8.RELEASE imports Java 8 compiled classSpring boot 1.5.8.RELEASE 导入 Java 8 编译类
【发布时间】:2018-04-06 22:06:02
【问题描述】:

我不知道我是否遗漏了什么,但我有一个 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。

【问题讨论】:

  • 最好使用 java 8 或 9。
  • Java 10 现已推出。您需要使用另一个 Boot 版本,或者使用 Undertow 或 Tomcat。你也可以考虑提交一个针对 Boot 的错误。
  • Spring Boot 向后兼容。在最坏的情况下,您可以使用嗅探器检查是否存在兼容性。请查看spring.io/blog/2015/04/03/…

标签: java spring-boot jetty htmlunit


【解决方案1】:

这里有两个不同的地方:Spring Boot 1.5.x 本身需要 JDK7+,但是这个要求可以根据你选择的容器而改变。

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

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

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-09-19
  • 1970-01-01
  • 2021-09-27
  • 2018-03-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多