You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring GraphQL项目启动报错:routerFunctionMapping Bean创建失败

问题解决:Spring GraphQL项目启动失败(BeanCreationException)

问题根源

启动时抛出org.springframework.beans.factory.BeanCreationException,核心原因是GraphQL schema定义中,Book类型的pageCount字段使用了不存在的INT类型,导致routerFunctionMapping Bean创建失败。

解决方案

修改schema.graphqls文件里Book类型的pageCount字段类型,将错误的INT替换为GraphQL标准的Int类型:

修改前的schema片段

type Book {
    id: ID!
    name: String!
    pageCount: INT!
    author: Author!
}

修改后的schema片段

type Book {
    id: ID!
    name: String!
    pageCount: Int!
    author: Author!
}

验证步骤

  • 保存修改后的schema.graphqls文件
  • 重新启动Spring应用
  • 查看启动日志,确认routerFunctionMapping Bean正常创建,无BeanCreationException抛出

补充说明

GraphQL标量类型区分大小写,官方标准标量类型为:

  • Int(32位整数)
  • Float(浮点数)
  • String(字符串)
  • Boolean(布尔值)
  • ID(唯一标识符)
    必须严格使用官方定义的大小写形式,否则会导致schema解析失败,进而触发Spring容器的Bean创建异常。

内容的提问来源于stack exchange,提问作者Mini

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 00:35:55