使用GAE的Spring Boot(Legacy) - 自动装配

时间:2015-06-25 11:24:18

标签: java spring maven google-app-engine spring-boot

我试图制作spring-boot-legacy:1.0.1.RELEASE& spring-boot-starter-parent:1.1.8.RELEASE,GAE 1.9.19。但是,在通过mvn appengine:devserver运行时,我收到以下错误,阻止应用程序运行:

[INFO] java.lang.NoClassDefFoundError: java.lang.reflect.Parameter is a restricted class. Please see the Google  App Engine developer's guide for more details.
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
[INFO]  at org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:53)
[INFO]  at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65)
[INFO]  at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1115)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
[INFO]  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
[INFO]  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
[INFO]  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
[INFO]  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
[INFO]  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
[INFO]  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
[INFO]  at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)

据我所知,Spring使用反射来自动连接依赖项,但似乎java.lang.reflect包中的某些类受到限制。关于如何使这项工作的任何想法?

2 个答案:

答案 0 :(得分:3)

Spring在Java 8下使用了

java.lang.reflect.Parameter。所以你必须降级到Java 7才能避免它。另一个原因是Google Appengine不支持Java 8,只支持Java 7.所以无论如何你都需要它。

答案 1 :(得分:0)

查看迁移指南 https://cloud.google.com/appengine/docs/standard/java/migrating-to-java8

将add <runtime>java8</runtime>添加到a​​ppengine-web.xml