Spring hibernate liquibase集成测试失败

Spring hibernate liquibase集成测试失败,hibernate,spring-boot,liquibase,Hibernate,Spring Boot,Liquibase,我可以使用liquibase正确运行我的应用程序。wer使用的环境包括spring、hibernate和mysql。当我尝试运行集成测试(具有h2 db)时,出现以下异常: Caused by: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLException: Schema "pbr_tenant" not found; SQL statement: Caused by: liquibase.exception.Datab

我可以使用liquibase正确运行我的应用程序。wer使用的环境包括spring、hibernate和mysql。当我尝试运行集成测试(具有h2 db)时,出现以下异常:

 Caused by: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLException: Schema "pbr_tenant" not found; SQL statement: Caused by: liquibase.exception.DatabaseException: org.h2.jdbc.JdbcSQLException: Schema "pbr_tenant" not found; SQL statement: SET SCHEMA pbr_tenant [90079-197]
            at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:307)
            at org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$DataSourceClosingSpringLiquibase.afterPropertiesSet(LiquibaseAutoConfiguration.java:218)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1803)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1740)
            ... 105 more Caused by: org.h2.jdbc.JdbcSQLException: Schema "pbr_tenant" not found; SQL statement: SET SCHEMA pbr_tenant [90079-197]
下面是用于集成测试的application.yml的外观

datasource:
  url: jdbc:h2:mem:data_import-int;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL
  platform: h2
  username: sa
  password:
  driverClassName: org.h2.Driver
jpa:
  database-platform: org.hibernate.dialect.H2Dialect
  properties:
    hibernate:
      show_sql: true
      use_sql_comments: true
      format_sql: true


 liquibase:
      url: jdbc:h2:mem:pbr_tenant;MODE=Mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;DATABASE_TO_UPPER=false;INIT=CREATE SCHEMA IF NOT EXISTS pbr_tenant;SCHEMA=pbr_tenant
      contexts: integration-test
      parameters:
        schema: pbr-tenant
      change-log: classpath:db/changelog/fini-changelog.yml

需要解决的问题是什么。

所以您似乎缺少模式。尝试以下方法

datasource:
  url: jdbc:h2:mem:data_import-int;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS pbr_tenant;MODE=MySQL
  platform: h2
  username: sa
  password:
  driverClassName: org.h2.Driver
如果架构不存在,则能够创建该架构。 您也可以尝试:

datasource:
  url: jdbc:h2:mem:data_import-int;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS pbr_tenant;SET SCHEMA pbr_tenant;MODE=MySQL
  platform: h2
  username: sa
  password:
  driverClassName: org.h2.Driver
要另外选择该模式