Skip to content
Advertisement

How to combine Testcontainers with @DataJpaTest avoiding code duplication?

I want to use Testcontainers with @DataJpaTest (and @SpringBootTest) using JUnit 5. I have the basic setup working using the @Testcontainers and @Container annotation like this: See https://github.com/wimdeblauwe/blog-example-code/tree/feature/testcontainers-datajpatest/testcontainers-datajpatest for the full example code (AtleteRepositoryTest, TeamRepositoryTest and TestcontainersDatajpatestApplicationTests). To avoid the repetition of declaring the PostgreSQL container and the dynamic properties, I tried the following: JUnit 5 extension Baeldung has a

Spring data rest resource inconsistently ‘discovered’ after restart

I’m using Spring Data Rest to expose rest endpoints which i can use in my user interface. However, during testing I noticed that when hitting the base rest url (http://localhost:8080/rest) , the endpoints are inconsistently exposed. I’m using the Annotation based RepositoryDetectionStrategies. I would appreciate some assistance in understanding and resolving the issue. Example: First boot: all endpoints are properly

Advertisement