Which Java version is supported by Spring Cloud?

岁酱吖の 提交于 2019-12-11 11:24:14

问题


Under http://start.spring.io (Initializr) you can create a Spring Cloud application for Java 6. The Spring Boot reference documentation still gives the hint that Java 6 is supported: http://docs.spring.io/spring-boot/docs/1.2.2.RELEASE/reference/htmlsingle/#howto-use-java-6 I can compile the generated "Initializr" project with Java 6, but when I try to run the application on Java 6 I get the following UnsupportedClassVersionError:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.cloud.bootstrap.BootstrapApplicationListener
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:381)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:358)
    at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:231)
    at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:206)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.daimler.daivb.services.common.configserver.ConfigserverApplication.main(ConfigserverApplication.java:16)
    ... 6 more
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/cloud/bootstrap/BootstrapApplicationListener : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:163)
    at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:249)
    at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:374)
    ... 12 more

So the question is, is it a mistake that the spring-cloud-context-1.0.1.RELEASE.jar:/org/springframework/cloud/bootstrap/BootstrapApplicationListener.class library has been compiled with Java 7 and target version Java 7?


回答1:


Spring Cloud requires Java 7 (except for one module that requires java 8). The Spring Cloud Commons readme will get updated with that information. I'll see about logging an issue with Initializr to not allow java 6 when spring cloud dependencies are chosen.



来源:https://stackoverflow.com/questions/30878637/which-java-version-is-supported-by-spring-cloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!