启动时不调用data.sql

问题描述 投票:0回答:1

我有以下application.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

java hibernate spring-boot spring-data
1个回答
0
投票

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

jpa: defer-datasource-initialization: true
© www.soinside.com 2019 - 2024. All rights reserved.