How do you customize error messages for validation in Spring?
Replace default Bean Validation messages using annotation attributes, message keys and MessageSource, then return clean JSON errors from a global handler.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Replace default Bean Validation messages using annotation attributes, message keys and MessageSource, then return clean JSON errors from a global handler.
@Valid runs Bean Validation on a submitted Spring form object. Build a Thymeleaf form with field errors, BindingResult and a custom constraint.
Use Jakarta Bean Validation with @Valid and one global exception handler to return consistent, field-level 400 errors from every Spring Boot endpoint.
Add 404.html and 500.html under templates/error to replace the Whitelabel page, or take control with a custom ErrorController or ErrorPageRegistrar.
Spring Boot reads configuration from files, profiles, environment variables and command-line arguments. Learn precedence and typed binding with records.
The application-{profile}.yml file holds settings that load only when a Spring profile is active, overriding application.yml for each environment.
Use @Profile, profile-specific property files and spring.profiles.active to run one Spring Boot build with different configuration in dev, test and production.
@ManagedResource turns a Spring bean into a JMX MBean so tools like JConsole can read attributes and call operations. It needs @EnableMBeanExport or Boot JMX.
Expose Spring beans as JMX MBeans with @ManagedResource and manage them from JConsole or VisualVM. Covers Boot settings and secure remote access.
CacheManager is Spring's registry of named caches. It connects cache annotations to a provider such as Caffeine or Redis without changing business code.
A practical guide to Spring's @Cacheable: key expressions, condition and unless, sync, multiple managers and the proxy pitfalls that disable caching.
@EnableAsync turns on Spring's @Async support so annotated methods run on a task executor. Learn return types, executor setup, virtual threads and exception handling.
Configure ThreadPoolTaskExecutor and the Spring Boot task properties correctly, understand how queue size controls growth, and choose rejection policies.
The @Async annotation runs a Spring bean method on a separate executor thread so the caller does not wait. See setup, return types, executors and pitfalls.
Add @EnableScheduling and annotate a method with @Scheduled(cron). This guide covers Spring's six-field syntax, time zones, intervals, externalised config and running jobs on several replicas.
TaskScheduler is Spring's abstraction for scheduling one-off and recurring tasks. See its methods, ThreadPoolTaskScheduler setup, cron triggers and common pitfalls.
@Scheduled lets a Spring bean method run repeatedly at fixed rates, delays or cron times. Learn how to enable it, write cron expressions and know its limits.
Build a WebSocket handler with TextWebSocketHandler or STOMP @MessageMapping in Spring 6+, including registration, session safety, origins and handshake checks.
WebSocketStompClient is Spring's client for STOMP over WebSocket. Learn how to configure it, connect with connectAsync, and handle messages and heartbeats.
Use ReactorNettyWebSocketClient to connect to a WebSocket server, send messages and process incoming frames as a Flux, with backoff-based reconnection.