title: Parameter 0 of constructor in Thomas.ChapterController required a bean of type 'Thomas.ChapterRepository' that could not be found
body: <p>I'm new to spring boot and I can't get an example from my spring boot book to work. Here is the code</p>
  
  <blockquote>
    <p>Description:</p>
    
    <p>Parameter 0 of constructor in Thomas.ChapterController required a bean of >type 'Thomas.ChapterRepository' that could not be found.</p>
    
    <p>Action:</p>
    
    <p>Consider defining a bean of type 'Thomas.ChapterRepository' in your configuration.</p>
  </blockquote>
  
  <p><strong>Chapter.java</strong></p>
  
  <pre><code>package Thomas;
  import lombok.Data;
  
  import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.mapping.Document;
  
  @Data
  @Document
  public class Chapter {
  
      @Id /*tells mongodb that this will be the primary key for Mongo Document */
      private String Id;
      private String name;
  
      public Chapter(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p><strong>ChapterRepository.java</strong></p>
  
  <pre><code>package Thomas;
  
  import org.springframework.data.repository.reactive.ReactiveCrudRepository;
  
  public interface ChapterRepository extends ReactiveCrudRepository&lt;Chapter, String&gt; {
  }
  </code></pre>
  
  <p><strong>LoadDatabase.Java</strong></p>
  
  <pre><code>package Thomas;
  
  import org.springframework.boot.CommandLineRunner;
  import org.springframework.context.annotation.Bean;
  import reactor.core.publisher.Flux;
  import org.springframework.context.annotation.Configuration;
  
  @Configuration /* Marks this class as a source of beans */
  public class LoadDatabase {
  
      @Bean /* Indicates that the return value of init is a Spring Bean */
      CommandLineRunner init(ChapterRepository repository) {
          return args -&gt; {
              Flux.just (
                      new Chapter("Quick Start With Java"),
                      new Chapter("Reactive Web With Spring Boot"),
                      new Chapter("...and More!"))
                      .flatMap(repository::save)
                      .subscribe(System.out::println);
  
          };
      }
  }
  </code></pre>
  
  <p><strong>ChapterController.java</strong></p>
  
  <pre><code>package Thomas;
  
  import reactor.core.publisher.Flux;
  
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  public class ChapterController {
  
      private final ChapterRepository repository;
  
      public ChapterController(ChapterRepository repository)
      {
          this.repository = repository;
      }
  
      @GetMapping("/chapters")
      public Flux&lt;Chapter&gt; listing() {
          return repository.findAll();
      }
  }
  </code></pre>
  
  <p><strong>ThomasSpringApplication.java</strong></p>
  
  <pre><code>package Thomas;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class ThomasSpringApplication {
  
      public static void main(String [] args) {
          SpringApplication.run(ThomasSpringApplication.class, args);
      }
  }
  </code></pre>