This sample shows how to utilize the Testcontainers usage with Spring Data JPA (and Spring Boot).
If you want to see the implementation in action, simply follow these steps:
- First, make sure that you have Java 8 or later installed and an established Internet connection.
- Then, make sure that you have a Postgresql database up and running and configured in a way that the properties in the application.yml match (or change the properties to match against your environment).
- Then, clone this Git repository an
cd
into the project folder. - Now invoke
./mvnw spring-boot:run
and wait a moment.
After the project is built and the Spring Boot service is running you have the following possibilities to act with the service:
- http://localhost:8080 allows to access this site.
- Access the administration tool of your database to realize the things that happened there.
A collection of the most important annotations and classes that are necessary to implement this use case.
- @GeneratedValue
- @Id
- @Repository
- @Transactional
- @DataJpaTest
- @AutoConfigureTestDatabase
- @ActiveProfiles
A collection of the mainly used frameworks in this project. There are more, but they are not that present inside the main use case, therefore they are not listed here.
The following guides illustrate how to implement this and related use cases.
This code is open source software licensed under the Apache 2.0 License.