Skip to main content

Spring Boot

Spring Boot — convention-over-configuration framework for building Spring-based Java applications

Mastering Maven: How to Create Your Own Custom Archetypes

Build a custom Maven archetype from scratch: create the descriptor, add Velocity-templated source files, install locally, generate a new Spring Boot project from it, and deploy to a team-shared repository. Step-by-step with working code.

Complete Guide to Logback RollingFileAppender

Master Logback RollingFileAppender with time-based, size-and-time, and fixed-window rolling policies. Includes production-ready logback.xml examples, Spring Boot integration, async logging, and a complete FAQ.

Building a REST API with Spring Boot: Complete Beginner's Guide

A complete beginner's guide to building a REST API with Spring Boot 3. Covers project setup, clean package structure, a Java record model with Bean Validation, a service layer, a @RestController with GET/POST/PUT/DELETE endpoints, global exception handling with @RestControllerAdvice, and end-to-end curl testing u2014 with fully annotated code throughout.

Testing Microservices with JUnit 6: Integration, Contract & E2E

A complete guide to testing microservices with JUnit 6: single-service integration tests with WireMock, consumer-driven contract tests with Spring Cloud Contract, and end-to-end tests with Docker Compose and Testcontainers. Covers async event testing and state management strategies.

Testing REST APIs with JUnit 6: MockMvc vs WebTestClient

A complete guide to testing REST APIs with JUnit 6 using both MockMvc and WebTestClient. Covers GET, POST, PUT, DELETE testing, JSON path assertions, validation error testing, file uploads, authentication, and a matcher quick-reference table.

JUnit 6 with Spring Boot: Unit, Slice, and Integration Testing

A complete guide to testing Spring Boot applications with JUnit 6. Covers unit tests with plain JUnit, slice tests (@WebMvcTest, @DataJpaTest, @JsonTest), full integration tests with @SpringBootTest, context caching, Testcontainers, and best practices for each layer.

A Developer’s Guide to Testing Spring REST Clients with @RestClientTest

In modern microservices architecture, it's rare for a service to live in complete isolation. Most applications need to communicate with other services over the network, typically via REST APIs. When you build a component that consumes an external REST API, a critical question arises: how do you test it reliably without actually making network calls to a live, and potentially unstable, external service? This is where Spring Boot's test slices come to the rescue. For testing your REST clients, the framework provides a powerful and elegant solution: the @RestClientTest annotation. Let's dive deep into how you can use it to write clean, fast, and reliable tests for your HTTP client components. What Exactly is @RestClientTest? @RestClientTest is a "test slice" annotation specifically designed to test REST client components. Instead of loading your entire Spring application context (like @SpringBootTest does), it focuses only on the beans relevant to REST client operations. This makes your tests significantly faster and less prone to side effects from unrelated configurations. When you use @RestClientTest, Spring Boot will auto-configure the following for you: The Client Under Test: The specific REST client bean you want to test. MockRestServiceServer: A bean that lets you mock the server-side responses. You can instruct it: "When my client calls /api/employees/1, respond with this specific JSON." RestTemplateBuilder: Used to help construct RestTemplate instances. Jackson/Gson Support: It automatically includes support for serializing and deserializing JSON, so you can test your client-side data mapping. In short, it provides the perfect, minimal environment to verify that your client builds the correct HTTP request and correctly parses the HTTP response — all without a single packet leaving your machine.

Mastering Hibernate 7 with Spring Boot 4: The Next-Gen Configuration & Performance Guide

Are you ready to move your data layer into the future? Configuring Hibernate 7 with Spring Boot 4 represents a significant milestone in the Java ecosystem. Spring Boot 4 (released November 2025) aligns with Jakarta EE 11 APIs, and Hibernate 7 introduces native JSON support and refined type systems — so developers are encountering new challenges, from namespace migrations to modern JVM targets (the baseline is Java 17, with Java 21 or 25 recommended for virtual threads). If your application feels stuck in the past, this guide is your roadmap to the cutting edge. In this deep-dive guide, we’ll explore the high-performance world of Spring Boot 4. We will cover the mandatory shifts in Jakarta Persistence 3.2, advanced performance tuning for virtual threads, and how to leverage Hibernate 7’s modern features to ensure your application on ankurm.com is ready for the evolving landscape of 2026 and beyond. The Problem: Legacy Debt in a Modern World Many applications are still tethered to the legacy javax.* namespace or older Hibernate versions that lack the efficiency of modern JVM features like Project Loom (Virtual Threads). Using outdated configurations leads to "Namespace Collision" errors and missed opportunities for the significant memory and performance optimizations anticipated in modern runtime environments. The Agitation: The Risk of Stagnation As Java moves toward the anticipated widespread adoption of Java 21 and the eventual standard of Java 25, staying on Spring Boot 2 or 3 becomes an increasing security and performance liability. Hibernate 7 introduces breaking changes in how it handles specific database dialects and type mappings. Failing to plan your migration now could lead to technical debt, incompatible libraries, and a data layer that cannot fully leverage modern hardware. The Solution: Harnessing Spring Boot 4 & Hibernate 7 Spring Boot 4 is built for speed, native compilation (GraalVM), and seamless integration with Hibernate 7. By migrating to the jakarta.persistence namespace and leveraging the "Unified Type System" introduced in Hibernate 7, we can build data layers that are significantly leaner and more performant.