Closed paul58914080 closed 3 years ago
Thanks for reporting.
This happens because @DataJpaTest
doesn't fire the Pre-Liquibase auto-configuration. (it fires DataSource auto-config, Liquibase auto-config, Hibernate auto-config and what not). This means, in your example, Pre-Liquibase never fires, so that when Liquibase fires it tries to create its tables in schema LIQUIBASE
... which hasn't been created, resulting in error.
As far as I understand @DataJpaTest
only triggers the auto-configuration relevant for JPA testing, not any/all Spring Boot auto-configuration. I'm investigating how Spring Boot figures out what that list is, exactly, so that I can get Pre-Liquibase Auto-Configuration class on that list.
In the meantime you can annotate your test with:
@DataJpaTest
@ImportAutoConfiguration(PreLiquibaseAutoConfiguration.class)
Yes this surely helps
Done!
Background: The magic that @DataJpaTest
does (meaning which auto-config to execute) is in spring.factories in the core Spring Boot.
Fix: The Pre-Liquibase auto-configuration has now been added to that list so that you can now use @DataJpaTest
without further ceremony.
Look for version 1.1.1 in Central Maven. It should be available shortly.
The example project has also been updated with a unit test example.
Fix for this issue:
Thank you so much for your quick response and fix :zap:
How to re-produce ?
Create a simple spring boot starter with jpa project (v 2.5.2) (or you can also use the example project)
Write a simple jpa test annotated with
@DataJpaTest
and application.yaml with propertyWhen you run a simple boot test, you would notice exception
Schema "LIQUIBASE" not found; SQL statement: