Dockerized PostgreSQL/MySQL with Snapshot Data for Spring Boot (JPA)

Guide to Spring Boot (JPA) using Dockerized PostgreSQL/MySQL with snapshot data. Add init scripts, profiles, and quick tests for faster development.
Spring Boot JPA with dockerized snapshot data

This guide demonstrates a Spring Boot + Spring Data JPA setup powered by Docker database images seeded with initial data, simplifying local development and staging.

The core dependencies of the example are as follows:

  • Spring Boot 2.5.0
  • Spring 5.3.7
  • Hibernate 5.4.31.Final
  • PostgreSQL driver 42.2.20
  • MySQL connector 8.0.25 (Alternative Database Option)

We are going to follow the listed steps throughout this example:

  1. Introduce PostgreSQL database as the default database for the application
  2. Create and run a PostgreSQL Docker image backed by initial data
  3. Add entities and repositories to the application
  4. Test the initial setup
  5. Introduce MySQL database as a secondary database option to the application
  6. Create and run a MySQL Docker image backed by initial data
Continue reading “Dockerized PostgreSQL/MySQL with Snapshot Data for Spring Boot (JPA)”

Testing Java Projects with Groovy

Testing java projects with groovy.

This example demonstrates how we can implement our tests using groovy in a java based project. You might be asking why. Well, implementing tests with groovy has some advantages like easier mock creation, expressive business readable test method names, seamless adaptation with BDD frameworks, and so on. If you want to investigate testing java projects with groovy, the article will, then, provide you a starting point for your investigation.

Continue reading “Testing Java Projects with Groovy”

Spring Boot Rest API Documentation Using Rest Assured Tests

Generating rest API documentation with rest-assured tests.

A clear and concise REST API documentation is mandatory for a rest API to be easily used. However, it’s error-prone and it is also hard to maintain API documentation if we attempt to write it manually. This sample project demonstrates how we can use rest assured tests along with spring boot to generate API documentation with a small amount of manual work.

Continue reading “Spring Boot Rest API Documentation Using Rest Assured Tests”