This project is an attempt to replicate this issue described on Stack Overflow.
The problem occurs with Flyway 4.1.2.
The spring-jdbc library needed to be added to the buildscript dependencies to get it working with 4.1.2.
It does work for Flyway 4.0.3 without this explicit dependency. Not sure why.
It is worth noting that the flyway-gradle-plugin was converted to java from groovy between these versions.
Optionally, use the included docker-compose.yml
to spin up a mysql container. (Requires docker
and docker-compose
, see the Installation Guide)
docker-compose up -d
Alternatively, update the database settings in build.gradle
as appropriate to point to an existing database.
Run the Flyway migration as follows:
./gradlew build flywayMigrate --stacktrace
To replicate the error, comment out the following line in build.gradle and re-run.
classpath("org.springframework:spring-jdbc:${springVersion}")
On the first run, it will give the following error
java.lang.NoClassDefFoundError: org/springframework/jdbc/core/JdbcTemplate
On all subsequent runs it will give the loader constraint violation
described in the issue.