Our testcontainers support should work with @RestartScope. It would be good to document this and have tests.

Comment From: mhalbritter

I can confirm that it works. However i found #35323 while testing it. When you move the testcontainers @Configuration class into src/main/java and annotate the bean method with @RestartScope, it works with devtools and the container survives the reloading.

Comment From: mhalbritter

One thing i found: When using @RestartScope, you need to change

developmentOnly 'org.springframework.boot:spring-boot-devtools'

to

testImplementation 'org.springframework.boot:spring-boot-devtools'

otherwise @RestartScope could not be found.

Comment From: mhalbritter

35323 is invalid. It works when using testImplementation configuration for devtools.

Comment From: mhalbritter

I've added some documentation in https://github.com/spring-projects/spring-boot/commit/1504e3043d8e134f90143239995ff141c86af7bc.