title: No qualifying bean of type available in SpringBoot Application
body: <p>When running my SpringBoot application, I am getting this error:  </p>
  
  <blockquote>
    <p>An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'bookController': Unsatisfied dependency expressed through field 'bookRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.experimental001.Repositories.BookRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} -> [Help 1]</p>
  </blockquote>
  
  <p>I have read through many posts regarding this error but none of them seem to fix my problem. </p>
  
  <p>I have tried adding the @Controller annotation but it doesn't seem to fix the bean problem. </p>
  
  <p>Controller:</p>
  
  <pre><code>@RestController
  @RequestMapping("/api/books")
  public class BookController {
  
      @Autowired
      private BookRepository bookRepository;
  
      @GetMapping
      public Iterable findAll() {
          return bookRepository.findAll();
      }
  
      @GetMapping("/title/{bookTitle}")
      public List findByTitle(@PathVariable String bookTitle) {
          return bookRepository.findByTitle(bookTitle);
      }
  
      @GetMapping("/{id}")
      public Book findOne(@PathVariable Long id) {
          return bookRepository.findById(id)
                  .orElseThrow(() -&gt; new BookNotFoundException("Book not found", null));
      }
  
      @PostMapping
      @ResponseStatus(HttpStatus.CREATED)
      public Book create(@RequestBody Book book) {
          return bookRepository.save(book);
      }
  
      @DeleteMapping("/{id}")
      public void delete(@PathVariable Long id) {
          bookRepository.findById(id).orElseThrow(() -&gt; new BookNotFoundException("Book not found", null));
          bookRepository.deleteById(id);
      }
  
      @PutMapping("/{id}")
      public Book updateBook(@RequestBody Book book, @PathVariable Long id) {
          if (book.getId() != id) {
              throw new BookIdMismatchException("error");
          }
          bookRepository.findById(id).
                  orElseThrow(() -&gt; new BookNotFoundException("Book not found", null));
          return bookRepository.save(book);
      }
  }
  </code></pre>
  
  <p>Simple Controller:</p>
  
  <pre><code>@Controller
  public class SimpleController {
      @Value("${spring.application.name}")
      String appName;
      @GetMapping("/")
      public String homePage(Model model) {
          model.addAttribute("appName", appName);
          return "home";
      }
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@EnableJpaRepositories
  @Repository
  
  public interface BookRepository extends CrudRepository&lt;Book, Long&gt; {
      public List&lt;Book&gt; findByTitle(String title);
  }
  </code></pre>
  
  <p>Pom:</p>
  
  <pre><code>&lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Application File:</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan(basePackages = BookRepository)
  
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>