java - TypeMappingException:检测到具有不同返回类型的操作“opName”的多个方法
问题描述
使用 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 没有帮助,甚至无法编辑或评论。
解决方案
删除 protobuf Timestamp 字段可以解决问题!
在更改了我的返回对象后,我不得不重构com.google.protobuf.Timestamp
为 Date、LocalDate 甚至是 String,它工作得很好。
推荐阅读
- javascript - 如何使用 lodash 将对象中的数组数据与计数分组
- sql-server - SSIS:无法运行 sql 任务来更新表
- java - 错误的 SQL 语法 - 在此 ResultSet 中找不到列名?
- c - iscntrl 的行为是什么?
- javascript - JavaScript:使用 reduce 函数的句子变体
- django - 如何获取外键 ID 以在 DetailView 中显示两个模型?
- performance - 如何正确 dockerize 并持续集成 20GB 原始数据?
- python - 原子装饰器会影响 Django 中链中的所有方法吗?
- go - 记录未知长度参数的大小控制
- sql-server - 抓取子级元素xml