【问题标题】:Flyway Found Non-Empty schema using H2 and REST-ASSUREDFlyway 发现使用 H2 和 REST-ASSURED 的非空模式
【发布时间】:2018-12-12 06:14:29
【问题描述】:

我正在尝试使用 SpringBoot、Flyway 和 H2 运行一些测试

我的 RestAssured 测试类扩展:

   @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
   @EnableConfigurationProperties
   public class FunctionalTest {
       @LocalServerPort
       private int port;
       public static final String JDBC_URL = "jdbc:h2:mem:FREE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL";
       @Value("${spring.datasource.username}")
       private String username;

       @Value("${spring.datasource.password}")
       private String password;

       @Before
       public void setUp() {
           Flyway flyway = new Flyway();
           flyway.setDataSource(JDBC_URL, username, password);
           flyway.setLocations("classpath:db/migration");
           flyway.migrate();
           AppContext.loadApplicationContext(this.context);
           RestAssured.port = this.port;

           CreateEntityUtil.init(organizationRepositoryInj, projectRepositoryInj, apiServerRepositoryInj, userServiceInj, userOrgServiceInj);
       }
   }

application.properties:

    spring.datasource.driver-class-name=org.h2.Driver
    spring.datasource.url=jdbc:h2:mem:FREE;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MYSQL
    spring.datasource.username=[EDITED]
    spring.datasource.password=[EDITED]

    flyway.locations=classpath:db/migration
    flyway.schemas=FREE

一些开发人员运行测试,一切都很好。 但其他人收到以下错误: Flyway 找到非空架构

【问题讨论】:

    标签: java spring-boot h2 flyway rest-assured


    【解决方案1】:

    如果有人遇到同样的问题,我使用以下方法解决了问题:

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 2014-10-23
      • 1970-01-01
      • 1970-01-01
      • 2017-09-04
      • 2019-04-09
      • 2020-05-24
      • 1970-01-01
      • 2020-07-16
      相关资源
      最近更新 更多