Spring Boot 启动时不调用data.sql

3mpgtkmj  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(57)

我有以下应用程序.yml:

spring:
  profiles: test
  jpa:
      hibernate:
        dialect: org.hibernate.dialect.H2Dialect
      generate-ddl: true
      ddl-auto: true
  datasource:
    url: jdbc:h2:mem:test_db;MODE=MSSQLServer
    username: sa
    password:
    data: data.sql
    continue-on-error: true
flyway:
  enabled: false

字符串
项目结构如下:


的数据
但启动时不会调用data.sql

zc0qhyus

zc0qhyus1#

你必须推迟运行data.sql直到hibernate创建表。将此添加到你的application.yml:

jpa: defer-datasource-initialization: true

字符串

相关问题