Closed ssprang closed 2 years ago
Hi @ssprang, thanks for the question. It seems to me that something in your application (a component, bean postprocessor, etc.) is enforcing initialization on these lazy beans. So please make sure that you are not autowiring or referencing any of these database providers in your application. And that even in some more generic way, e.g. autowiring List<DatabaseProvider> providers
can also cause this problem. Additionally, make sure you are not using any processor or other feature that enforces early initialization of spring beans.
Ah, thank you! ππ»
I debugged, put a breakpoint on io.zonky.test.db.config.EmbeddedDatabaseAutoConfiguration#zonkyPostgresDatabaseProvider
and found a bad class in the project initializing all beans, just like you suspected. Also, thanks for the quick feedback!! β π
Hi! ππ» I'm trying to upgrade to
io.zonky.test:embedded-database-spring-test:2.1.1
from version1.6.3
and I'd like to use the postgresql testcontainer. It's a spring boot, maven, kotlin project using flyway for migrations (Spring boot version2.6.0
, flyway-spring-test7.0.0
, flyway-core8.0.4
) and I have this in my test application.properties:I can see that the docker container starts ok, the flyway migrations run ok but the application fails to start due to this:
The project shouldn't use the
zonkyPostgresDatabaseProvider
in the first place.. But if I do as directed by the log message and add embedded-postgres to my dependencies, then the application fails to start with:So it's like the application is trying to start all database providers even though I have specifically requested docker and postgres.
It makes no difference if I move the settings from application.properties to the
@AutoConfigureEmbeddedDatabase
annotation.Does anyone know what I'm doing wrong?