Spring Cloud支持哪个Java版本?

时间:2015-06-16 21:34:10

标签: spring spring-boot spring-cloud

http://start.spring.io(Initializr)下,您可以为Java 6创建Spring Cloud应用程序。 Spring Boot参考文档仍然提供了支持Java 6的提示:http://docs.spring.io/spring-boot/docs/1.2.2.RELEASE/reference/htmlsingle/#howto-use-java-6 我可以使用Java 6编译生成的“Initializr”项目,但是当我尝试在Java 6上运行应用程序时,我得到以下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

所以问题是,使用Java 7和目标版本编译spring-cloud-context-1.0.1.RELEASE.jar:/org/springframework/cloud/bootstrap/BootstrapApplicationListener.class库是错误的吗? Java 7?

1 个答案:

答案 0 :(得分:2)

Spring Cloud需要Java 7(一个需要java 8的模块除外)。 Spring Cloud Commons自述文件将更新该信息。我会看到使用Initializr记录一个问题,以便在选择spring cloud依赖项时不允许使用java。