简体   繁体   English

使用H2和REST-ASSURED的Flyway发现非空模式

[英]Flyway Found Non-Empty schema using H2 and REST-ASSURED

I'm trying to run some tests using SpringBoot, Flyway and H2 我正在尝试使用SpringBoot,Flyway和H2运行一些测试

My RestAssured test classes extends: 我的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: 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

Some developers run the tests and everything is fine. 一些开发人员运行测试,一切都很好。 But others get the following error: Flyway Found non-empty Schema 但是其他人会收到以下错误:Flyway找到非空模式

In case anyone is facing the same issue, I solved the problem using: 如果有人遇到相同的问题,我可以使用以下方法解决该问题:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM