Use this file to discover all available pages before exploring further.
Spring Boot’s IO support covers everything from making outbound HTTP calls and caching expensive computations, to sending email, scheduling jobs, processing batches, and exposing gRPC services. Each area is backed by a dedicated auto-configuration that activates when the right dependency is on the classpath.
HTTP clients
RestClient, WebClient, and RestTemplate for imperative and reactive outbound HTTP calls.
Caching
@Cacheable, @CachePut, @CacheEvict backed by Redis, Caffeine, Hazelcast, and more.
Email
JavaMailSender auto-configuration via spring-boot-starter-mail for SMTP email sending.
Validation
Bean Validation 1.1 with Hibernate Validator, @Valid, @Validated, and constraint annotations.
Quartz scheduler
spring-boot-starter-quartz for cron-based and trigger-based job scheduling.
Spring Batch
Batch job processing with in-memory, JDBC, or MongoDB job repositories.
gRPC
spring-boot-starter-grpc-server and spring-boot-starter-grpc-client for Protocol Buffers RPC.
Spring Boot provides various convenient ways to call remote REST services. Use RestClient for imperative (blocking) applications, WebClient for reactive applications, or RestTemplate for legacy code.
RestClient
WebClient
HTTP Service interfaces
Spring Boot creates and pre-configures a prototype RestClient.Builder bean. Inject the builder into your components to create RestClient instances:
MyService.java
@Servicepublic class MyService { private final RestClient restClient; public MyService(RestClient.Builder restClientBuilder) { this.restClient = restClientBuilder .baseUrl("https://api.example.com") .build(); } public User getUser(Long id) { return restClient.get() .uri("/users/{id}", id) .retrieve() .body(User.class); }}
Apply SSL configuration using an SSL bundle:
MyService.java
@Servicepublic class MyService { private final RestClient restClient; public MyService(RestClient.Builder restClientBuilder, RestClientSsl ssl) { this.restClient = restClientBuilder .apply(ssl.fromBundle("my-ssl-bundle")) .build(); }}
Configure global timeouts for all auto-configured clients:
If Spring WebFlux is on the classpath, use WebClient for non-blocking HTTP calls. Spring Boot creates and pre-configures a prototype WebClient.Builder bean:
MyService.java
@Servicepublic class MyService { private final WebClient webClient; public MyService(WebClient.Builder webClientBuilder) { this.webClient = webClientBuilder .baseUrl("https://api.example.com") .build(); } public Mono<User> getUser(Long id) { return webClient.get() .uri("/users/{id}", id) .retrieve() .bodyToMono(User.class); }}
Spring Boot auto-detects the HTTP connector in this order of preference: Reactor Netty, Jetty RS client, Apache HttpClient, JDK HttpClient.Apply SSL from a bundle:
MyService.java
@Servicepublic class MyService { private final WebClient webClient; public MyService(WebClient.Builder webClientBuilder, WebClientSsl ssl) { this.webClient = webClientBuilder .apply(ssl.fromBundle("my-ssl-bundle")) .build(); }}
Instead of using RestClient or WebClient directly, define annotated Java interfaces and import them:
EchoService.java
public interface EchoService { @GetExchange("/echo") String echo(@RequestParam String message);}
Import the service using @ImportHttpServices on your main application class:
MyApplication.java
@SpringBootApplication@ImportHttpServices(types = EchoService.class, group = "echo")public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); }}
Configure the group’s base URL in application.yaml:
Spring Boot auto-configures the cache infrastructure when caching support is enabled with @EnableCaching. It selects a cache provider from your classpath — Redis, Caffeine, Hazelcast, Infinispan, JCache, or a simple in-memory ConcurrentHashMap as a fallback.Add the starter:
@Servicepublic class MyMathService { @Cacheable("piDecimals") public int computePiDecimal(int precision) { // expensive computation return computeActualPiDecimal(precision); } @CacheEvict(value = "piDecimals", allEntries = true) public void clearCache() {}}
Before invoking computePiDecimal, Spring looks for an entry in the piDecimals cache matching the precision argument. If found, the cached value is returned immediately without invoking the method.
Avoid adding @EnableCaching to your main application class. Doing so makes caching mandatory, including when running test slices that do not need it.
Annotate your service class with @Validated and use constraint annotations on parameters:
MyBean.java
@Service@Validatedpublic class MyBean { public Archive findByCodeAndFormatWithSomeCodeAndAnotherCode( @Size(min = 8, max = 10) String code, @NotNull Format format) { return archiveRepository.findByCode(code); }}
Use @Valid in controllers to trigger validation on request bodies:
MyController.java
@RestControllerpublic class MyController { @PostMapping("/users") public User createUser(@Valid @RequestBody CreateUserRequest request) { return userService.create(request); }}
Spring Boot offers several conveniences for working with the Quartz scheduler, including the spring-boot-starter-quartz starter. A Scheduler is auto-configured through SchedulerFactoryBean.
By default, the database is detected and initialized using standard scripts provided with the Quartz library. These scripts drop existing tables, deleting all triggers on every restart. Use spring.quartz.jdbc.schema to point to a custom script if you need to preserve triggers between restarts.
Define a job with dependency injection:
MySampleJob.java
@Componentpublic class MySampleJob extends QuartzJobBean { private final MyService myService; public MySampleJob(MyService myService) { this.myService = myService; } @Override protected void executeInternal(JobExecutionContext context) { myService.doWork(); }}
Spring Boot offers several conveniences for working with Spring Batch, including running a Job on startup automatically when a single Job bean is found in the application context.Supported job repository stores:
In-memory — for development and testing
JDBC — for production, with configurable table prefix
MongoDB — document-based job metadata
application.yaml
spring: batch: jdbc: table-prefix: "CUSTOM_" job: enabled: true # set to false to prevent auto-run on startup
Spring Boot includes support for developing and testing both client and server gRPC applications using spring-boot-starter-grpc-server and spring-boot-starter-grpc-client.
For testing, use @AutoConfigureTestGrpcTransport to replace gRPC channels with in-process test channels. This avoids needing to listen on a real network port and makes tests run faster.