How to add the mode=mysql to embedded H2 DB in Spring Boot 1.4.1 for @DataJpaTest?

前端 未结 5 2139
自闭症患者
自闭症患者 2020-12-18 20:41

I have some problems with using a schema.sql file to create my sql schema when executing a junit test while this schema contains mysql specific expression. I have to add the

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 21:15

    You need to set MYSQL mode on h2 and disable replacing of datasource url for embedded database:

    Modify application-test.yaml

    spring:
      datasource:
        url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=MYSQL  
      test:
        database:
          replace: NONE
    

提交回复
热议问题