Spring boot 1.5.8.RELEASE导入Java 8编译类

时间:2018-04-06 22:06:02

标签: java spring-boot jetty htmlunit

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

确实升级了1.5.8.RELEASE的spring-boot https://github.com/spring-projects/spring-boot/issues/10396

那么......我错过了什么吗?春天启动1.5.8 Java 7兼容吗?

编辑:https://github.com/eclipse/jetty.project/issues/2151 那么......我应该降级我的弹簧版本吗?我还无法通过Java 7。

1 个答案:

答案 0 :(得分:1)

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

Jetty 9.3+需要JDK8,但使用Jetty 9.2应该可以使用JDK7(参见as described by theanalogkid in Apple's dev forums)。

通过更改private DocParserFactory docParserFactory; // You can inject either the real instance (DocParserFactoryImpl) or a // test instance which returns dummy parsers with predicable results // when you construct this object. public ThisObject(DocParserFactory docParserFactory) { this.docParserFactory = docParserFactory; } ... // Your code public void someMethod() { ... FirestoreRecyclerOptions<Model1> fro1 = new FirestoreRecyclerOptions.Builder<Model1>() .setQuery(query1, docParserFactory.getModel1Parser()) .build(); FirestoreRecyclerOptions<Model2> fro2 = new FirestoreRecyclerOptions.Builder<Model2>() .setQuery(query2, docParserFactory.getModel2Parser()) .build(); ... } maven属性来降低您的码头依赖性应该足够了。

Spring Boot构建示例应用程序以演示兼容性 - Spring Boot 1.5.x system requirements page