In a Spring Boot
(2.1.3) project, I try to run an integration test against a memory H2 database (2.1.210). I also insert some data in Spring's data.sql
.
I annotated the tests with @AutoConfigureTestDatabase
and all worked as expected. Now I wanted to change the compatibility mode, and I find no option for doing that.
How can I customize the H2 database if I want AutoConfigureTestDatabase to create a new database for each test?
So far, I tried:
spring.test.database.replace=none
spring.datasource.url=jdbc:h2:mem;DB_CLOSE_DELAY=1;
But I ran into 'table already exists' or 'Unique constraing violation' because it seems the system does not remove the database, instead it re-executes the script on top of the existing one. The problem is described here: https://stackoverflow.com/a/47897350/3429660
I also tried to not use AutoConfigureTestDatabase, but I ran into the same problem.