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

前端 未结 5 2123
自闭症患者
自闭症患者 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:11

    I was having this same issue. It would not pick up the url when running tests. I'm using flyway to manage my scripts. I was able to get all of these working together by following these few steps.

    Created a V1_init.sql script in src/test/resources/db/migration so that it is the first script run by flyway.

    SET MODE MYSQL; /* another h2 way to set mode */
    
    CREATE SCHEMA IF NOT EXISTS "public"; /* required due to issue with flyway --> https://stackoverflow.com/a/19115417/1224584*/
    

    Updated application-test.yaml to include the schema name public:

    flyway:
      schemas: public
    

    Ensure the test specified the profile: @ActiveProfiles("test")

提交回复
热议问题