Spring Boot 1.5.20 / GraphQl java 'Json' 支持的扩展标量在应用程序启动期间提供 java.lang.NoClassDefFoundError
Sring Boot 1.5.20 / GraphQl java extended scalar for 'Json' support gives java.lang.NoClassDefFoundError during application startup
我正在尝试使用 spring boot 1.5.20 集成 graphql。
我包含了扩展标量库以提供对 'JSON' 类型的支持。
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>2018-10-05T23-44-12-5312ccd</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
我需要使用标量类型 json。
为此,我定义了一个@Bean注解的方法来配置扩展标量。
@Bean
public GraphQLScalarType jsonType() {
return ExtendedScalars.Json;
}
我还在架构文件中包含了 'scalar JSON'。
当我添加 @Bean 注释方法为 JSON 配置扩展标量时,我得到“工厂方法 'jsonType' 抛出异常;嵌套异常是 java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException' 应用程序启动时出错
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonType' defined in class path resource [.../configuration/GraphQLConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLScalarType]: Factory method 'jsonType' threw exception; nested exception is java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1317)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1283)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1097)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1067)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583)
... 77 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLScalarType]: Factory method 'jsonType' threw exception; nested exception is java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 92 common frames omitted
Caused by: java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at graphql.scalars.datetime.DateTimeScalar.<init>(DateTimeScalar.java:27)
at graphql.scalars.ExtendedScalars.<clinit>(ExtendedScalars.java:40)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration.jsonType(GraphQLConfiguration.java:29)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0.CGLIB$jsonType(<generated>)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0$$FastClassBySpringCGLIB$cc9cfe.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0.jsonType(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 93 common frames omitted
任何人都可以建议我使用它的方式 missing/wrong 是什么吗?感谢任何帮助。
Caused by: java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at graphql.scalars.datetime.DateTimeScalar.<init>(DateTimeScalar.java:27)
at graphql.scalars.ExtendedScalars.<clinit>(ExtendedScalars.java:40)
graphql-java-extended-scalars
需要自 graphql-java 8.0
以来引入的 class CoercingParseLiteralException
。但是,您使用的是非常旧的 graphql-java
版本,即 6.0,因此它没有此 class 并抛出 NoClassDefFoundError
。
解决方案是更新 graphql-spring-boot-starter
和 graphql-java-tools
版本,使它们使用相同版本的 graphql-java
,至少是版本 8。
您可以使用 mvn dependency:tree
检查包含哪个版本的 graphql-java
。
我正在尝试使用 spring boot 1.5.20 集成 graphql。 我包含了扩展标量库以提供对 'JSON' 类型的支持。
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-tools</artifactId>
<version>4.3.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>2018-10-05T23-44-12-5312ccd</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
我需要使用标量类型 json。 为此,我定义了一个@Bean注解的方法来配置扩展标量。
@Bean
public GraphQLScalarType jsonType() {
return ExtendedScalars.Json;
}
我还在架构文件中包含了 'scalar JSON'。
当我添加 @Bean 注释方法为 JSON 配置扩展标量时,我得到“工厂方法 'jsonType' 抛出异常;嵌套异常是 java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException' 应用程序启动时出错
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonType' defined in class path resource [.../configuration/GraphQLConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLScalarType]: Factory method 'jsonType' threw exception; nested exception is java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1317)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1283)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1097)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1067)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583)
... 77 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLScalarType]: Factory method 'jsonType' threw exception; nested exception is java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 92 common frames omitted
Caused by: java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at graphql.scalars.datetime.DateTimeScalar.<init>(DateTimeScalar.java:27)
at graphql.scalars.ExtendedScalars.<clinit>(ExtendedScalars.java:40)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration.jsonType(GraphQLConfiguration.java:29)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0.CGLIB$jsonType(<generated>)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0$$FastClassBySpringCGLIB$cc9cfe.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.logmein.assets.orchestrationservice.configuration.GraphQLConfiguration$$EnhancerBySpringCGLIB$d7c6c0.jsonType(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 93 common frames omitted
任何人都可以建议我使用它的方式 missing/wrong 是什么吗?感谢任何帮助。
Caused by: java.lang.NoClassDefFoundError: graphql/schema/CoercingParseLiteralException
at graphql.scalars.datetime.DateTimeScalar.<init>(DateTimeScalar.java:27)
at graphql.scalars.ExtendedScalars.<clinit>(ExtendedScalars.java:40)
graphql-java-extended-scalars
需要自 graphql-java 8.0
以来引入的 class CoercingParseLiteralException
。但是,您使用的是非常旧的 graphql-java
版本,即 6.0,因此它没有此 class 并抛出 NoClassDefFoundError
。
解决方案是更新 graphql-spring-boot-starter
和 graphql-java-tools
版本,使它们使用相同版本的 graphql-java
,至少是版本 8。
您可以使用 mvn dependency:tree
检查包含哪个版本的 graphql-java
。