Best of Baeldung2025

  1. 1
    Article
    Avatar of baeldungBaeldung·37w

    Spring Boot 4 & Spring Framework 7 – What’s New

    Spring Boot 4 and Spring Framework 7 introduce significant modernization updates including Java 17 baseline with Java 21/25 support, Jakarta EE 11 alignment, and Kotlin 2.2+ compatibility. Key features include enhanced GraalVM native image support, built-in API versioning, declarative HTTP clients with @HttpServiceClient, resilience annotations for retry logic, improved observability with Micrometer 2 and OpenTelemetry, modular architecture for better performance, and JSpecify null safety adoption. The releases also bring testing improvements with context pausing and RestTestClient, while removing deprecated javax.* packages and Jackson 2.x support.

  2. 2
    Article
    Avatar of baeldungBaeldung·38w

    How to Reduce Spring Boot Memory Usage?

    Spring Boot applications typically consume significant memory (150+ MB) due to JVM architecture, embedded server threads, and framework overhead. Memory usage can be reduced through JVM tuning (serial garbage collector, reduced thread stack size, RAM limits), configuring web server thread pools, container-aware deployment practices, and removing unused dependencies. Key techniques include using -XX:+UseSerialGC, -Xss512k for thread stacks, setting MaxRAM limits, reducing Tomcat threads to 20, and matching JVM flags to container limits.

  3. 3
    Article
    Avatar of baeldungBaeldung·1y

    How to Convert Nested Loops to Stream in Java

    Java Streams, introduced in Java 8, offer a declarative and efficient way to handle data by replacing complex nested loops. This post explores transforming nested loops into Streams, covering basic operations, filtering, and short-circuiting iterations. It highlights how streams can simplify complex transformations, improve readability, and enable parallel execution. However, for simple or performance-critical tasks, traditional loops may be more suitable.

  4. 4
    Article
    Avatar of baeldungBaeldung·1y

    Decreasing IntelliJ RAM Usage

    Learn how to decrease IntelliJ IDEA's RAM usage by optimizing memory settings, disabling unused plugins, adjusting garbage collection, and enabling Power Save Mode. These steps help improve performance and ensure a smoother development experience.

  5. 5
    Article
    Avatar of baeldungBaeldung·1y

    Thread per Connection vs Thread per Request

    This post compares two server threading models: thread-per-connection and thread-per-request. It defines the terms 'connection' and 'request', discusses their implementation in Java web servers, and highlights the advantages and disadvantages of each model. Thread-per-connection involves a dedicated thread for each client connection, while thread-per-request uses a new thread for each request, regardless of connection status. The choice between these models depends on factors like scalability, context switching, and expected traffic patterns.

  6. 6
    Article
    Avatar of baeldungBaeldung·1y

    Introduction to Apache Kylin

    Apache Kylin is an open-source OLAP engine designed for sub-second query performance on massive datasets. Initially developed by eBay and later managed by the Apache Software Foundation, it excels in handling high concurrency and integrates seamlessly with Hadoop and data lake platforms. Key features include multidimensional modeling, optimized indexing, and support for both batch and streaming data sources. The platform can be easily explored using Docker, allowing for straightforward setup, model creation, and CUBE building via SQL and REST API.

  7. 7
    Article
    Avatar of baeldungBaeldung·45w

    Introduction to Jimmer ORM

    Jimmer ORM is a new database framework that differs from JPA by requiring developers to specify data interaction details at the call site rather than through annotations. It uses interfaces as entities and relies heavily on DTOs for both reading and writing data. The framework includes a dedicated DTO language to reduce manual DTO creation overhead and supports multiple databases including MySQL, PostgreSQL, and Oracle. Unlike Hibernate, Jimmer doesn't implement dirty checking or traditional lazy loading, instead focusing on explicit data shape specification through DTOs and Object Fetcher APIs.

  8. 8
    Article
    Avatar of baeldungBaeldung·23w

    What’s New in Maven 4

    Maven 4 introduces significant improvements after 15 years since Maven 3. Key updates include POM version 4.1.0, build/consumer POM separation for cleaner dependency resolution, new artifact types for explicit classpath and module path control, and renaming 'modules' to 'subprojects' to avoid confusion with Java modules. The release adds a tree-based lifecycle for better multi-project performance, before/after phase hooks, condition-based profile activation, and a unified sources section for custom source directories. An upgrade tool helps migrate from Maven 3, while maintaining backward compatibility with version 4.0.0 POMs.

  9. 9
    Article
    Avatar of baeldungBaeldung·1y

    Introduction to RESTHeart

    RESTHeart is a Java-based framework designed to build HTTP APIs on top of MongoDB, automatically exposing collections as REST and GraphQL endpoints. It offers CRUD operations, role-based access, and authentication out of the box with minimal setup, providing a zero-code solution. This tutorial guides on running RESTHeart locally or via Docker, setting up authentication, and performing CRUD operations both through REST and GraphQL APIs.

  10. 10
    Article
    Avatar of baeldungBaeldung·48w

    Introduction to DiceDB

    DiceDB is an open-source, high-performance in-memory database that offers Redis-like commands with modern features such as reactive queries. The tutorial covers installation via Docker, connecting through the DiceDB CLI, and performing basic operations like SET, GET, DEL, PING, ECHO, TYPE, and EXISTS commands. DiceDB runs on port 7379 by default and provides a developer-friendly experience for real-time applications with familiar key-value operations.

  11. 11
    Article
    Avatar of baeldungBaeldung·49w

    Cleaning Spring Properties Files

    Spring Properties Cleaner is a Maven plugin that automatically cleans up Spring application properties files by removing duplicates, standardizing formatting, sorting keys, and extracting common properties across multiple profile-specific files. The plugin can be configured to detect issues during builds, sort properties in clustered or alphabetical order, inline prefixes for better commonality extraction, and manage vertical whitespace. It supports three extraction modes (full, consistent, multiple) for promoting properties to a common application.properties file, helping maintain cleaner and more organized configuration files in Spring projects.

  12. 12
    Article
    Avatar of baeldungBaeldung·46w

    A Practical Guide to RecordBuilder in Java

    RecordBuilder is a Java library that enhances Java records with builder pattern functionality through annotation processing. It generates fluent builders, withX() methods, and consumer-based modification capabilities while maintaining immutability. The library eliminates boilerplate code for creating flexible object construction patterns and automatically stays synchronized with record structure changes, making it more maintainable than manual builder implementations.

  13. 13
    Article
    Avatar of baeldungBaeldung·1y

    Implement Feature Flags in Java With Unleash

    Feature flags, or feature toggles, enable the activation and deactivation of application functionalities without altering the codebase. Unleash is an open-source tool for managing these flags across multiple environments. This guide walks through setting up Unleash locally, configuring a feature toggle, and integrating them into a Java application using Spring Boot. The setup ensures features can be toggled in real-time, improving development cycles and enabling controlled feature rollouts.

  14. 14
    Article
    Avatar of baeldungBaeldung·41w

    Implementing CQRS with Spring Modulith

    CQRS (Command Query Responsibility Segregation) separates write operations from read operations using different optimized models. Spring Modulith helps structure applications into loosely coupled modules organized by business capability rather than technical concerns. The implementation uses domain events for asynchronous communication between modules, with the command side handling ticket booking/cancellation and the query side managing movie searches and seat availability. Spring Modulith's @ApplicationModuleListener enables eventual consistency through the transactional outbox pattern, while jMolecules annotations clarify architectural roles.

  15. 15
    Article
    Avatar of baeldungBaeldung·1y

    How to Run a Java Program in the Background

    Learn various methods to run a Java application as a background process, keep it running after terminal closure, and monitor it using logs. Explore the use of '&' operator, nohup, systemd services, screen, and tmux for effective process management.

  16. 16
    Article
    Avatar of baeldungBaeldung·24w

    Introduction to Netflix Hollow

    Netflix Hollow is a low-latency Java framework for distributing data from a source to multiple targets using a producer-consumer model. The producer fetches data from external systems and publishes snapshots to file systems or object storage, while consumers read and process these snapshots. The framework efficiently manages memory by offloading large datasets to external storage, addressing Java heap space issues. Implementation involves defining entity classes with primary keys, setting up publishers and announcers for producers, generating consumer APIs using HollowAPIGenerator, and configuring announcement watchers and retrievers for consumers. The library handles snapshot versioning, updates, and notifications automatically.

  17. 17
    Article
    Avatar of baeldungBaeldung·51w

    Event-Driven LISTEN/NOTIFY Support in Java using PostgreSQL

    PostgreSQL's LISTEN and NOTIFY commands enable asynchronous communication between database server and clients, creating a simple messaging system. The LISTEN command registers interest in receiving events on specific channels, while NOTIFY broadcasts messages to all listeners. Java applications can raise notifications using standard JDBC with either NOTIFY commands or pg_notify() function. Listening for notifications requires driver-specific functionality - the official PostgreSQL JDBC driver requires polling with getNotifications(), while PGJDBC-NG provides callback-based listeners for more efficient event handling. This mechanism supports real-time dashboards, cache invalidation, and data auditing use cases.

  18. 18
    Article
    Avatar of baeldungBaeldung·1y

    Stream Gatherers in Java

    Java 24 introduces the Gatherer interface, enhancing Java Stream APIs by allowing more flexible intermediate operations. Gatherers facilitate custom data transformations and support asynchronous processing. The article explores built-in Gatherers and demonstrates creating custom Gatherers for diverse input-output mappings, demonstrating how these can be used for one-to-one, one-to-many, many-to-one, and many-to-many relationships.

  19. 19
    Article
    Avatar of baeldungBaeldung·45w

    How to Implement a Thread-Safe Singleton in Java?

    Explores multiple approaches to implementing thread-safe Singleton patterns in Java, including synchronized methods, eager initialization, double-checked locking, Bill Pugh pattern, and enum singletons. Compares their performance trade-offs and provides practical examples with test code to demonstrate thread safety in concurrent environments.

  20. 20
    Article
    Avatar of baeldungBaeldung·1y

    Kafka Producer and Consumer Message Acknowledgement Options

    The tutorial explains the acknowledgment options available for producers and consumers in Apache Kafka, detailing how the three producer acknowledgment modes (none, leader, and all) impact message reliability and system performance. It also covers essential consumer configuration properties, such as group ID, auto offset reset, enable auto commit, and auto commit interval, which affect consumer message processing and reliability. Understanding these options allows developers to balance performance and reliability for different use cases.

  21. 21
    Article
    Avatar of baeldungBaeldung·44w

    Introduction to Smithy

    Smithy is an Interface Definition Language (IDL) developed by Amazon for describing APIs in a language and protocol-agnostic format. It enables automatic generation of both client SDKs and server stubs from API definitions, serving as a single source of truth. The tutorial covers defining resources, operations, and services using Smithy syntax, then demonstrates how to use Gradle plugins to generate Java client and server code. Smithy focuses on resource-based APIs and supports various protocols like JSON over HTTP, offering more opinionated structure compared to OpenAPI or RAML while providing flexibility in transport and serialization methods.

  22. 22
    Article
    Avatar of baeldungBaeldung·30w

    Introduction to BaseX

    BaseX is a lightweight XML database that stores, queries, and manipulates XML data using XQuery and XPath. It offers multiple interfaces including a GUI, command-line tool, and HTTP REST API. The tutorial covers installation requirements (Java 17+), basic database operations (creating, opening, dropping databases), resource management (adding, deleting XML files), querying with XQuery, and HTTP server setup with authentication. The REST API enables programmatic access to databases and resources, supporting CRUD operations through standard HTTP methods.

  23. 23
    Article
    Avatar of baeldungBaeldung·1y

    Integrating Jolokia With Spring Boot

    Learn how to integrate Jolokia with a Spring Boot application to monitor your application via API endpoints. This tutorial covers initial setup, basic commands for interacting with MBeans, and methods to secure Jolokia endpoints by restricting access through configuration.

  24. 24
    Article
    Avatar of baeldungBaeldung·49w

    Introduction to Ambassador Design Pattern

    The Ambassador Design Pattern acts as a network proxy between clients and servers, encapsulating networking components like retry logic, caching, timeouts, and circuit breakers in a reusable component. It can be implemented as a library dependency within the same container or as a separate sidecar container exposing REST APIs. The pattern promotes code reusability and maintainability by centralizing network communication logic, but introduces potential latency and availability concerns when deployed as a separate service.

  25. 25
    Article
    Avatar of baeldungBaeldung·51w

    Authorize Request for Certain URL and HTTP Method in Spring Security

    Spring Security provides flexible mechanisms to authorize requests based on URLs, HTTP methods, and user roles. The tutorial demonstrates implementing role-based access control in a blogging platform where users can manage their own posts while admins have broader permissions. Key concepts include configuring SecurityFilterChain for URL-based authorization, using @PreAuthorize for method-level security, implementing custom UserDetailsService for database authentication, and creating service layers that enforce business logic with proper access controls. The implementation covers user registration, authentication, and CRUD operations with appropriate security constraints.