title: Required a bean of type that could not be found Spring Boot
body: <p>Spring Boot application fails to start?</p>
  
  <p><a href="https://i.stack.imgur.com/R5wwK.png" rel="nofollow noreferrer">Here is my Project Structure</a></p>
  
  <p>Below is my main class.</p>
  
  <pre><code>package com.example;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
      @SpringBootApplication
      public class Start {
          public static void main(String[] args) {
              SpringApplication.run(Start.class, args);
          }
      }
  </code></pre>
  
  <p>And my console is </p>
  
  <pre><code>2017-11-28 11:48:52.187  WARN 7316 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.repository.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  Description:
  
  Field userRepository in com.example.controller.UserController required a bean of type 'com.example.repository.UserRepository' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'com.example.repository.UserRepository' in your configuration.
  </code></pre>
  
  <p>Application.properties</p>
  
  <pre><code>spring.data.mongodb.host=localhost
  spring.data.mongodb.port=27017
  spring.data.mongodb.database=example
  </code></pre>
  
  <p>UserRepository interface</p>
  
  <pre><code>package com.example.repository;
  
  import org.springframework.data.mongodb.repository.MongoRepository;
  
  import com.example.model.User;
  
  public interface UserRepository extends MongoRepository&lt;User, String&gt;{
      public User findOneByName(String name);
  }
  </code></pre>
  
  <p>Here is my controller</p>
  
  <pre><code>@RestController
  @RequestMapping("/user/")
  public class UserController {
      @Autowired
      public UserRepository userRepository;
      @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
      public void create(@RequestBody User user){
          userRepository.save(user);
      }
  }
  </code></pre>