A repo for my article, Building with the Latest Java Development Stack: Spring Boot 4.1.0, Java 25, Docker 29.5.3, PostgreSQL, Gradle 9.6.0, Eclipse 2026–06, Swagger/OpenAPI, Serenity, Cucumber, and JUnit 6 A practical hands-on tutorial showing how to combine the latest Java, Spring Boot, Docker, PostgreSQL, Gradle, Swagger/OpenAPI, Serenity, Cucumber, and JUnit 6 in one working project using a vibe-coding approach.
The article can be found here.
This repository contains a working example of a modern Spring Boot 4.1.0 / Java 25 application using PostgreSQL in Docker, Gradle 9.6.0, Eclipse 2026-06, Swagger/OpenAPI through springdoc, and automated testing with JUnit 6, Cucumber, and Serenity BDD.
The goal is not to teach every technology from scratch. Instead, this project provides a small but realistic baseline where all of these tools work together in one coherent setup. It can be used as a reference project for experimenting with Spring Boot 4, Java 25, PostgreSQL, modern Gradle builds, API documentation, and graphical test reporting.
| Area | Technology |
|---|---|
| Language | Java 25 |
| Framework | Spring Boot 4.1.0 |
| Build tool | Gradle 9.6.0 |
| IDE used in the article | Eclipse 2026-06 |
| Database | PostgreSQL 18.4 in Docker |
| Docker version used in the article | Docker Desktop 4.79 / Docker 29.5.3, |
| API documentation | springdoc OpenAPI / Swagger UI |
| Unit and slice testing | JUnit 6 / JUnit Jupiter, Mockito, Spring Boot Test |
| BDD/API reporting | Serenity BDD 5.3.9 |
| Feature files | Cucumber 7.21.1 / Gherkin |
Finding a working combination of recent versions across Spring Boot, Java, Gradle, PostgreSQL, Swagger/OpenAPI, Serenity, Cucumber, and JUnit can take time. Online examples are often outdated or use incompatible combinations.
This project demonstrates one working combination that was compiled, executed, tested, and validated locally. AI tools were used as fast technical collaborators during development, but generated code and configuration were reviewed, corrected, compiled, and tested manually.
The application manages a simple book table in PostgreSQL.
CREATE TABLE book (
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
title VARCHAR(200) NOT NULL,
author VARCHAR(120) NOT NULL,
isbn VARCHAR(20) NOT NULL,
published_date DATE,
price NUMERIC(10, 2),
stock_quantity INTEGER NOT NULL,
description VARCHAR(1000),
CONSTRAINT uk_book_isbn UNIQUE (isbn),
CONSTRAINT ck_book_price_nonnegative CHECK (price IS NULL OR price >= 0),
CONSTRAINT ck_book_stock_nonnegative CHECK (stock_quantity >= 0)
);The REST API supports:
- Listing all books.
- Creating a new book.
- Finding a book by numeric database id.
- Updating an existing book.
- Deleting a book by id.
- Searching books by author text, case-insensitively.
- Finding a book by ISBN.
Swagger UI is used to explore and manually test the API. Serenity and Cucumber are used to demonstrate automated API/BDD reporting.
Install or have available:
- Docker Desktop 4.75 or later.
- Docker Engine 29.5.2 or later.
- JDK 25.
- Gradle 9.5.1, or use the included Gradle wrapper.
- Eclipse 2026-06, preferably Eclipse IDE for Enterprise Java and Web Developers.
- Optional: DBeaver for GUI database inspection.
- Optional on Windows: Cmder.
Pull the latest PostgreSQL image:
docker pull postgres:latestCreate and start the PostgreSQL container:
docker run --name pg-akrivitsky -e POSTGRES_USER=akrivitsky -e POSTGRES_PASSWORD=your_password_here -e POSTGRES_DB=swagger_demo -p 5432:5432 -v pgdata_akrivitsky:/var/lib/postgresql -d postgres:latestImportant note for PostgreSQL 18+ Docker images: the persistent volume is mounted at:
/var/lib/postgresql
This is the correct mount location for persistent database storage for the PostgreSQL 18+ Docker image used in this project.
Verify the PostgreSQL version:
docker exec -it pg-akrivitsky psql -U akrivitsky -d swagger_demoExpected version in the article:
psql (18.4 (Debian 18.4-1.pgdg13+1))
Verify the Docker volume mount:
docker inspect pg-akrivitsky --format "{{json .Mounts}}"The important part of the output should be:
"Destination":"/var/lib/postgresql"SpringBoot4FeaturesSwaggerSerenityPostgres/
├── gradle
│ ├── libs.versions.toml
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew.bat
├── lib
│ ├── build.gradle
│ └── src
│ ├── main
│ │ ├── java
│ │ │ └── dev
│ │ │ └── anatoly
│ │ │ └── swaggerdemo
│ │ │ ├── SwaggerDemoApplication.java
│ │ │ ├── config
│ │ │ │ └── OpenApiConfig.java
│ │ │ ├── controller
│ │ │ │ └── BookController.java
│ │ │ ├── dto
│ │ │ │ ├── BookCreateRequest.java
│ │ │ │ ├── BookResponse.java
│ │ │ │ └── BookUpdateRequest.java
│ │ │ ├── entity
│ │ │ │ └── Book.java
│ │ │ ├── exception
│ │ │ │ ├── GlobalExceptionHandler.java
│ │ │ │ └── ResourceNotFoundException.java
│ │ │ ├── repository
│ │ │ │ └── BookRepository.java
│ │ │ └── service
│ │ │ └── BookService.java
│ │ └── resources
│ │ ├── application.yaml
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ ├── java
│ │ └── dev
│ │ └── anatoly
│ │ └── swaggerdemo
│ │ ├── SwaggerDemoApplicationTests.java
│ │ ├── controller
│ │ │ └── BookControllerTest.java
│ │ ├── cucumber
│ │ │ ├── BookStepDefinitions.java
│ │ │ └── RunCucumberTest.java
│ │ ├── entity
│ │ │ └── BookTest.java
│ │ ├── exception
│ │ │ └── GlobalExceptionHandlerTest.java
│ │ ├── serenity
│ │ │ └── WhenManagingBooks.java
│ │ └── service
│ │ └── BookServiceTest.java
│ └── resources
│ ├── features
│ │ └── books
│ │ └── search_books.feature
│ ├── junit-platform.properties
│ └── serenity.properties
└── settings.gradle
Configures the root Gradle project and includes the lib subproject. It also applies the Foojay toolchain resolver convention plugin, which allows Gradle to auto-provision JDK 25 together with the Java toolchain declaration in build.gradle.
Configures:
- Java 25 toolchain support.
- Spring Boot 4.1.0.
- PostgreSQL JDBC driver.
- springdoc OpenAPI / Swagger UI.
- JUnit 6 / JUnit Jupiter testing.
- Cucumber feature-file testing.
- Serenity BDD reporting.
Although the Serenity artifact is named serenity-junit5, it is used here with JUnit 6 because it integrates with the JUnit Jupiter extension model. JUnit Jupiter remains the modern test API used by annotations such as @Test and @ExtendWith.
Configures the datasource, JPA validation, SQL initialization, virtual threads, and springdoc paths.
Notable settings include:
spring:
threads:
virtual:
enabled: trueand springdoc paths such as:
springdoc:
swagger-ui:
path: /swagger-ui.html
api-docs:
path: /v3/api-docsIf Eclipse marks valid Spring Boot properties such as server.port or springdoc.* as “not allowed” in application.yaml, check the YAML schema validation settings. In the article, Wild Web Developer incorrectly applied an Enonic XP schema from SchemaStore. Disabling automatic YAML schema pulling from JSON Schema Store removed the false validation errors.
schema.sql creates the book table. data.sql inserts sample books for immediate API testing.
SwaggerDemoApplication.java— Spring Boot application entry point.OpenApiConfig.java— OpenAPI metadata and server configuration.Book.java— JPA entity mapped to thebooktable.- DTO records — request/response payloads with validation and schema annotations.
BookRepository.java— Spring Data JPA repository.BookService.java— transactional service layer.BookController.java— REST controller with Swagger/OpenAPI annotations.GlobalExceptionHandler.java— centralizedProblemDetailerror handling.ResourceNotFoundException.java— application-specific 404 exception.
- Make sure the PostgreSQL Docker container is running.
- In Eclipse, select
SwaggerDemoApplication.java. - Choose
Run As → Java Application. - Open Swagger UI in the browser:
http://localhost:8080/swagger-ui/index.html
In Eclipse, right-click SpringBoot4FeaturesSwaggerSerenityPostgres-lib in the Package Explorer and select:
Coverage As → JUnit Test
The article target was more than 70% coverage.
SwaggerDemoApplicationTests is a minimal @SpringBootTest smoke test. Its contextLoads() method does not need explicit assertions; the test passes if the Spring application context starts successfully.
Open Cmder in the root Gradle project directory:
SpringBoot4FeaturesSwaggerSerenityPostgres
Do not run the command from the parent eclipse-workspace directory.
Run:
gradlew :lib:clean :lib:cucumberTest :lib:aggregate --rerun-tasksThe Serenity report is generated at:
lib/target/site/serenity/index.html
From the same root project directory, run:
gradlew :lib:clean :lib:test --tests "*WhenManagingBooks*" :lib:aggregate --rerun-tasksThis demonstrates Serenity REST testing directly from JUnit 6 / JUnit Jupiter tests, without Gherkin and without .feature files.
This project demonstrates two Serenity styles:
- Cucumber + Serenity — uses
.featurefiles written in Gherkin together with Java step definitions. - JUnit 6 + Serenity REST — uses ordinary JUnit/Jupiter test classes without
.featurefiles.
Files involved:
RunCucumberTestBookStepDefinitionssearch_books.featureWhenManagingBooks
Serenity can be integrated into a CI/CD pipeline, for example, a Jenkins-based pipeline, so that test results for each build can be documented.
Swagger UI is useful for quick manual testing before moving on to structured automated testing. It can also be useful for controlled smoke testing after deployment.
In production, use a dedicated test tenant, a dedicated test account, or clearly marked records that are isolated from real business data and excluded from normal reporting.
Copyright (c) 2026 Anatoly S. Krivitsky, Ph.D.
All rights reserved.
Permission is granted, free of charge, to use, copy, distribute, and publish this code, provided that the copyright notice and permission notice are preserved.
This code is provided "as is", without warranty of any kind. The user assumes all responsibility and risk for its use. Under no circumstances shall the author be liable for damages, lost profits, data loss, business interruption, or other losses arising from the use of, inability to use, or reliance on this code.
See LICENSE for complete usage terms.
Anatoly S. Krivitsky, Ph.D.