What is the role of the CorsConfiguration class in Spring Boot?
CorsConfiguration is the Spring object that describes a CORS policy. Learn its settings and how to apply it globally with Spring MVC and Spring Security.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
CorsConfiguration is the Spring object that describes a CORS policy. Learn its settings and how to apply it globally with Spring MVC and Spring Security.
Map a multi-column primary key in JPA using @EmbeddedId or @IdClass, with runnable Jakarta Persistence examples, @MapsId and Spring Data usage.
Configure CORS in a Spring Boot REST API globally, per controller and with Spring Security 6, and learn how to debug preflight failures.
@Embedded stores an embeddable value object in the owning entity's table. Learn column overrides, queries, null handling and when to use an entity instead.
Design a consistent JSON error contract for a Spring Boot REST API with custom exceptions, @RestControllerAdvice, validation details and ProblemDetail.
Use a @Version field so JPA rejects stale updates with an OptimisticLockException, then retry or return a conflict to the user.
@EntityListeners runs listener classes on JPA lifecycle events such as persist and update. Learn custom listeners and Spring Data JPA auditing.
@ExceptionHandler lets a Spring Boot API return clean, consistent error responses. See ProblemDetail, validation handling and MockMvc tests.
Make repository.delete() update a flag instead of removing the row. Covers Hibernate @SoftDelete, @SQLDelete, restoring rows and pitfalls with batch deletes.
Learn how to centralise exception handling in Spring Boot with @RestControllerAdvice, custom exceptions and ProblemDetail responses that follow RFC 9457.
@DeleteMapping maps HTTP DELETE requests to controller methods in Spring MVC. Learn status codes, idempotency, error handling and security for REST delete endpoints.
@CreatedDate lets Spring Data set an entity's creation time on first save. See the auditing setup, a reusable base class, AuditorAware and why the field can stay null.
A complete Spring Boot setup for Spring Data JPA auditing, from the audit columns and base entity to the current user and a test.
Map each HTTP verb to a controller method with @GetMapping, @PostMapping, @PutMapping, @PatchMapping and @DeleteMapping, and return correct status codes.
TransactionTemplate wraps a transaction manager in a callback API so you can run code transactionally without begin, commit and rollback boilerplate.
Learn how to start, commit and roll back Spring transactions in code with TransactionTemplate and PlatformTransactionManager, with working examples.
@Valid triggers Jakarta Bean Validation on Spring Boot request bodies and nested objects. Learn setup, error handling with ProblemDetail and common pitfalls.
@Transactional runs a method inside a database transaction and rolls back on runtime exceptions. See propagation, isolation and common pitfalls.
Add the validation starter, annotate DTOs with Jakarta constraints, use @Valid on the request body and return clean 400 errors with ProblemDetail.
Define an event record, publish it with ApplicationEventPublisher and handle it with @EventListener. Covers async listeners, transactional events and conditions.