spring-boot
spring-boot copied to clipboard
Test and document @RestartScope with testcontainers
Our testcontainers support should work with @RestartScope. It would be good to document this and have tests.
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.
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.
#35323 is invalid. It works when using testImplementation configuration for devtools.
I've added some documentation in https://github.com/spring-projects/spring-boot/commit/1504e3043d8e134f90143239995ff141c86af7bc.