The reactive repository

Our Plane class needs a repository to persist the data to a database. We will use a reactive repository for MongoDB provided by the Spring Reactive MongoDB implementation. We will use the ReactiveCrudRepository as it makes our repositories reactive. Our repository should be like this:

package springfive.airline.airlineplanes.repository;import org.springframework.data.repository.reactive.ReactiveCrudRepository;import springfive.airline.airlineplanes.domain.Plane;public interface PlaneRepository extends ReactiveCrudRepository<Plane,String>{}

The implementation is the same as it was in the previous Spring Data versions, except for the new reactive interface. Now, we can create our service layer in the next section.

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.