Pulling data through a Mono/Flux and chain of operations

We have wired up a repository to interface with MongoDB through Spring Data. Now we can start hooking it into our ImageService.

The first thing we need to do is inject our repository into the service, like this:

    @Service 
    public class ImageService { 
      ... 
      private final ResourceLoader resourceLoader; 
 
      private final ImageRepository imageRepository; 
 
      public ImageService(ResourceLoader resourceLoader, 
       ImageRepository imageRepository) { 
         this.resourceLoader = resourceLoader; 
         this.imageRepository = imageRepository; 
      } 
      ... 
    } 

In the previous chapter, we loaded Spring's ResourceLoader. In this chapter, we are adding ImageRepository to our constructor.

Previously, we looked up the names of the existing ...

Get Learning Spring Boot 2.0 - Second Edition 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.