Skip to content

spring-boot with flyway and how to get your tests working

spring-boot with flyway and how to get your tests working published on No Comments on spring-boot with flyway and how to get your tests working

Sharing is caring!

Problem

You have a spring boot application with flyway migration scripts for a MySQL database. Now your tests are failing because you don’t have the database available during unit testing and flyway is complaining.

Solution

Use an in memory H2 database in MySql mode.

How

  • Create a file called flyway_init.sql in src/test/resources with the following content

  • create an application.yml file in src/test/resources with the following flyway config:

  • Add a test dependency on h2 to the pom.xml

  • Have fun.

Leave a Reply

Your email address will not be published. Required fields are marked *

Primary Sidebar