0

使用 graphql-spqr 和 Spring Boot,我正在尝试运行该项目,但我遇到了这个问题:

exception:org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'graphQLSchema' defined in class path resource 
[io/leangen/graphql/spqr/spring/autoconfigure/SpqrAutoConfiguration.class]: 
Bean instantiation via factory method failed; 
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; 
nested exception is io.leangen.graphql.metadata.exceptions.TypeMappingException: 
Multiple methods detected  for operation "defaultInstanceForType" with different 
return types. Types found: [com.google.protobuf.Message, com.google.protobuf.MessageLite]. 
If this is intentional, and you wish GraphQL SPQR to infer the most common super type automatically, see 
https://github.com/leangen/graphql-spqr/wiki/Errors#operation-with-multiple-resolver-methods-of-different-types 

我被重定向到这个寻求帮助:https ://github.com/leangen/graphql-spqr/wiki/Errors#operation-with-multiple-resolver-methods-of-different-types

我没有触发我的多个同名方法,异常中的 URL 没有帮助,甚至无法编辑或评论。

4

1 回答 1

0

删除 protobuf Timestamp 字段可以解决问题!

在更改了我的返回对象后,我不得不重构com.google.protobuf.Timestamp为 Date、LocalDate 甚至是 String,它工作得很好。

于 2020-07-09T13:41:31.507 回答