解决springboot整合h2数据库访问web端出现404

首先先放上我的配置文件

spring:
  application:
    name: h2
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true
      path: /h2
  datasource:
    url: jdbc:h2:mem:dbtest
    username: sa
    password: sa
    driverClassName: org.h2.Driver
  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    show-sql: true
    hibernate:
      ddl-auto: update

这里需要注意一个是spring.h2.console.enable,不配置的话是false,是不予许访问的
其实要注意path,默认是你的tomcat地址/h2-console
如果上述配置依然解决不了问题
是不是前端配置的是webFlux,推荐使用web,虽然不知道是什么bug

你可能感兴趣的:(spring,h2,spring,boot,数据库,web)