spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Test and document @RestartScope with testcontainers

Open philwebb opened this issue 2 years ago • 4 comments

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

philwebb avatar Apr 28 '23 19:04 philwebb

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.

mhalbritter avatar May 05 '23 12:05 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.

mhalbritter avatar May 05 '23 12:05 mhalbritter

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

mhalbritter avatar May 05 '23 12:05 mhalbritter

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

mhalbritter avatar May 09 '23 08:05 mhalbritter