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

配置application.properties后访问H2控制台仍出现白标错误页

解决H2控制台访问白标错误的问题

你的配置里存在几处拼写和层级错误,导致H2控制台的配置未被正确加载:

  • 配置前缀大小写错误:原配置的Spring:首字母大写,Spring Boot配置对大小写敏感,必须改为小写spring:,否则配置不会生效。
  • 配置项拼写错误:
    • onsole.settings.trace缺少字母c,正确应为console.settings.trace
    • scpring.h2.console.settings.web-allow-others里的scpring是拼写错误,应为spring
  • 配置层级错误:web-allow-others属于h2.console.settings的子项,不能单独作为顶级配置存在

修正后的完整配置如下:

server:
    port: 8080
spring:
    h2:
      console:
        enabled: true
        path: /h2-console
        settings:
          trace: false
          web-allow-others: false
    datasource:
        url: jdbc:h2:mem:testdb
        username: sa
        password:
        driverClassName: org.h2.Driver
    jpa:
        show-sql: true
        defer-datasource-initialization: true
        database-platform: org.hibernate.dialect.H2Dialect

修正后重启应用,访问http://localhost:8080/h2-console即可正常打开H2控制台。另外请确保项目已正确引入H2数据库依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 08:35:22