How do you define request mapping in Spring Boot?
Learn how @RequestMapping and the HTTP-method shortcuts map URLs to controller methods in Spring Boot, with path variables, params and content negotiation.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Learn how @RequestMapping and the HTTP-method shortcuts map URLs to controller methods in Spring Boot, with path variables, params and content negotiation.
@RestController marks a Spring class whose methods write return values to the response body. See how it differs from @Controller, with examples.
A complete Spring Boot REST API with Spring Data JPA, CRUD endpoints, validation, consistent error responses and tests.
A gRPC load balancer turns resolved addresses into subchannels and picks one per RPC. See pick_first, round_robin, xDS and how to write a custom policy.
@Primary tells Spring which bean to inject by default when several share a type. A Spring Boot two-DataSource example shows how it works with @Qualifier.
gRPC keeps one HTTP/2 connection, so plain TCP balancing fails. Configure round_robin, DNS targets and headless services in Spring Boot to spread calls.
Route each request to a different database in Spring using AbstractRoutingDataSource, from multi-tenant routing to read replicas, with safe context handling.
AbstractRoutingDataSource lets a single DataSource pick a target database at runtime from a lookup key. Learn multi-tenant routing, read/replica splitting and common pitfalls.
StatusRuntimeException is the unchecked grpc-java exception that wraps a gRPC Status. See how to return errors from servers, handle them in clients and add details.
Define one DataSource per database, mark one @Primary, and give each its own JPA entity manager factory and transaction manager.
Mark read-only service methods with @Transactional(readOnly = true) to skip Hibernate flushing and enable replica routing, and learn why it is a hint, not a guarantee.
Return the right gRPC status codes from Spring Boot services, map exceptions in one @GrpcAdvice class, and handle StatusRuntimeException on the client.
StreamObserver is gRPC Java's callback interface for sending and receiving message streams. See how it powers server, client and bidirectional streaming.
REQUIRES_NEW suspends the active transaction and runs the method in a separate one. See batch and audit use cases, rollback outcomes and pitfalls.
Understand all seven Spring propagation levels, when to use REQUIRES_NEW or NESTED, and why propagation settings are sometimes ignored.
@Rollback controls whether a Spring test transaction is rolled back or committed after each test. See the defaults, @Commit and what rollback does not undo.
TransactionTemplate runs code in a transaction without annotations. See execute, rollback, propagation and timeout settings, and when to prefer @Transactional.
Implement gRPC server, client and bidirectional streaming in Spring Boot with StreamObserver, a complete proto file, working client code and deadline handling.
TransactionSynchronizationManager is Spring's thread-bound registry for transaction resources and callbacks. See how it works and when to use it directly.
ManagedChannel is the long-lived client connection in gRPC Java. Learn how to build, share, configure and shut it down correctly.