How do you create a reactive REST API in Spring Boot?
Build a full reactive REST API in Spring Boot with WebFlux and R2DBC, including validation, error handling and tests, and learn when reactive is worth it.
2,881 posts about Java: questions with answers, tutorials and articles, newest first.
Build a full reactive REST API in Spring Boot with WebFlux and R2DBC, including validation, error handling and tests, and learn when reactive is worth it.
Build non-blocking Spring Boot services with WebFlux, Mono, Flux, R2DBC and WebClient, and learn when virtual threads are the better choice.
MongoRepository is Spring Data's interface for MongoDB data access, giving you CRUD, paging and derived queries without writing implementations. See how to use it with examples.
Add the Spring Data MongoDB starter, map a class with @Document and extend MongoRepository to get CRUD methods and derived queries with no implementation code.
Add spring-boot-starter-data-mongodb, set the connection URI, map a Document class and use MongoRepository or MongoTemplate for CRUD and custom queries.
Configure Spring Boot with two databases using separate DataSource, EntityManagerFactory and transaction manager beans, @Primary and one repository package per database.
Create custom Spring Boot configuration with @Configuration classes, type-safe @ConfigurationProperties records, profiles and conditional beans.
@PropertySource adds an external properties file to the Spring Environment. See how to inject its values, load optional files, and when Spring Boot offers a better option.
Create a Spring Boot configuration class with @Configuration and @Bean, bind typed properties with @ConfigurationProperties and vary settings per profile.
Bind application.properties or application.yml values to a validated @ConfigurationProperties record, and override them per environment with profiles.
The starter that moves Spring Boot to Log4j 2 is spring-boot-starter-log4j2, not log4j-spring-boot-starter. Here is the exact Maven and Gradle setup.
Spring Boot logs through SLF4J with Logback by default. See how to switch to Log4j2, configure levels and rolling files, and enable structured logs.
@Timed turns a method into a Micrometer timer that records call count and duration. It needs a TimedAspect bean and Spring AOP to take effect.
Register custom Micrometer metrics in Spring Boot with MeterRegistry, choose between counters, timers and gauges, and expose them through Actuator and Prometheus.
Implement HealthIndicator as a bean, return Health.up() or Health.down(), and expose the Actuator health endpoint to report custom checks.
Actuator adds health, metrics and management endpoints to a Spring Boot app. See how to expose, secure and extend them for production.
@RequestMapping routes inbound HTTP requests to controller methods. See how to expose external endpoints and call third-party APIs with RestClient.
Use WebClient in Spring Boot to call REST APIs with GET and POST requests, error handling, timeouts and retries, and learn when RestClient fits better.
RestTemplate simplified calling REST APIs from Spring. See how it works, its status today and how RestClient and WebClient replace it.
Call third-party REST APIs from Spring Boot with RestClient, WebClient or an HTTP interface, and handle timeouts, errors and retries properly.