H2数据库在创建架构之前首先运行脚本

时间:2016-10-21 14:45:23

标签: spring-boot h2

我正在尝试使用内存数据库H2进行一些测试。在我的情况下,我正在尝试创建模式并使用一些数据加载模式。

我遇到的问题是,当我运行测试时,它会尝试先运行脚本而不创建架构,但我得到的errror表不存在。

application-test.yml文件

spring:

      datasource:
          driver-class-name: org.h2.Driver
          url: jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS sample\;runscript from '~/LoadData.sql'

      jpa:
        hibernate:
          ddl-auto: create-drop
        properties:
          hibernate:
            default_schema: sample

application.yml

server:
  port: 0
spring:
  application:
    name: services
  devtools:
    livereload:
        enabled: false
  jpa:
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
        default_schema: ${APP_DATASOURCE_SCHEMA}
        temp:
          use_jdbc_metadata_defaults: false
    hibernate:
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
    jackson:
      serialization:
        indent-output: true
logging:
  level:
    com.application: DEBUG
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
  instance:
    leaseRenewalIntervalInSeconds: 3
    leaseExpirationDurationInSeconds: 4
sample:
  application:
    portrange:
      min: 8090
      max: 8099
    sendemail: false
ldap:
  contextSource:
    url: ${LDAP_URL}
    base: ${LDAP_BASE}
    userDn: ${LDAP_USER_DN}
    password: ${LDAP_PASSWORD}

0 个答案:

没有答案