@RestController
public class MovieController {
private final MovieRepository movieRepository;
public MovieController(MovieRepository movieRepository) {
this.movieRepository = movieRepository;
}
// Notice the return type
@GetMapping("/movies")
public Flux getAllMovies() {
return movieRepository.findAll();
}
}
When application requirements call for high-throughput data processing, WebFlux is an ideal solution.
Java persistence with Spring Data
Spring Data is a highly sophisticated, persistence-aware framework that has been refined over the years. In addition to supporting Java’s Jakarta Persistence API, Spring provides easy entry to newer approaches such as the following repository class. Note that this class does not require any annotation because Spring Boot recognizes it subclasses a persistence base-class:
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
public interface MovieRepository extends ReactiveCrudRepository {
// You define the method signature; Spring Data R2DBC provides the implementation
Flux findByGenre(String genre);
}
This code uses Spring R2DBC, a relational database connection library that uses asynchronous reactive drivers. The beauty is that the engine itself provides the implementation based on the fields and methods of the data object; as the developer, you do not have to implement the findByGenre method.



