Spring Docker Compose Support arrived in Spring Boot 3.1. I have set this up to start and tear down the Docker services when doing ./gradlew bootRun and this works fine. The docs then say one should use the custom dependency handling developmentOnly to avoid bundling it:

dependencies {

When running @SpringBootTest tests they fail on creating beans, as the services are not spun up and this is expected, as the official docs say that the support is disabled by default when running tests:

By default, Spring Boot’s Docker Compose support is disabled when running tests. To enable it, set spring.docker.compose.skip.in-tests to false.

I have then done this, but still it failed. There was no indication of the Docker Compose Support being loaded at all, actually, which made me wonder if the instructions really were correct … So, just for kicks, I changed developmentOnly to implementation and lo and behold: it worked!

So it seems that developmentOnly is not sufficient to make the dependency available at runtime when running tests, so either I am missing some config or the Spring docs and/or implementation for Gradle are wrong.

Is there a way to make this work in Gradle currently without inadvertently bundling the optional dependency?

Related, unanswered questions that seem to indicate this is not new:

  • Spring Boot 3.1 RC1 Docker Compose can not be activated for Integration Tests
  • Spring Boot 3.1 with compose and postgres dependencies fails running contextLoad test