title: SpringBoot: Unsatisfied dependency NoSuchBeanDefinitionException, expected at least 1 bean which qualifies as autowire candidate
body: <p>I am making a very silly mistake but not able to figure out how to fix.</p>
  
  <p>I have a simple SpringBoot app using profiles, which connect to MongoDb.</p>
  
  <p>My <strong>pom.xml</strong> dependencies:</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.3.RELEASE&lt;/version&gt;
  &lt;/parent&gt;
  &lt;dependencies&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-test&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-mongodb&lt;/artifactId&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>
  
  <p>My <strong>StudentController.java</strong></p>
  
  <pre><code>@RestController
  @RequestMapping("/students")
  public class StudentController {
  
      @Autowired
      private StudentService studentService;
  
      @RequestMapping(method = RequestMethod.GET)
      public Collection&lt;Student&gt; getAllStudents(){
          return studentService.getAllStudents();
      }
  }
  </code></pre>
  
  <p>My <strong>StudentService.java</strong></p>
  
  <pre><code>@Service
  public class StudentService {
  
      @Autowired
      private StudentDao studentDao;
  
      public Collection&lt;Student&gt; getAllStudents(){
          return this.studentDao.getAllStudents();
      }
  }
  </code></pre>
  
  <p>My <strong>StudentDao.java</strong> interface:</p>
  
  <pre><code>public interface StudentDao {
      Collection&lt;Student&gt; getAllStudents();
  }
  </code></pre>
  
  <p>My <strong>MongoStudentDaoImpl.java</strong>:</p>
  
  <pre><code>@Repository
  @Profile("test")
  public class MongoStudentDaoImpl implements StudentDao {
  
      @Autowired
      private MongoStudentRepo repo;
  
      @Override
      public Collection&lt;Student&gt; getAllStudents() {
          return repo.findAll();
      }
  }
  </code></pre>
  
  <p>My <strong>MongoStudentRepo.java</strong>: </p>
  
  <pre><code>@Profile("test")
  public interface MongoStudentRepo extends MongoRepository&lt;Student, String&gt; {
  }
  </code></pre>
  
  <p>When I am trying to start the application using the "test" profile, here is the error I am seeing:</p>
  
  <blockquote>
    <p>Exception encountered during context initialization - cancelling
    refresh attempt:
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'studentController': Unsatisfied
    dependency expressed through field 'studentService'; nested exception
    is org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'studentService': Unsatisfied dependency
    expressed through field 'studentDao'; nested exception is
    org.springframework.beans.factory.UnsatisfiedDependencyException:
    Error creating bean with name 'mongoStudentDaoImpl': Unsatisfied
    dependency expressed through field 'repo'; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    qualifying bean of type 'MongoStudentRepo' available:
    expected at least 1 bean which qualifies as autowire candidate.
    Dependency annotations:
    {@org.springframework.beans.factory.annotation.Autowired(required=true)}</p>
  </blockquote>
  
  <p>What am I missing in here? Do I need to add an annotation to <code>MongoStudentRepo.java</code>?</p>
  
  <p>Thanks in advance.</p>