title: Expected at least 1 bean which qualifies as autowire candidate in Test
body: <p>I'm new in Spring. I am creating a console application using Spring Boot. The application works fine, but when I try to test the Repository, I get an error</p>
  <p><code>Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'universityManagerSpringBootApplication': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.universitymanager.springboot.engine.ResponseGenerator' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}</code></p>
  <p>Please help</p>
  <p><strong>ResponseGenerator</strong></p>
  <pre><code>@Component
  @AllArgsConstructor
  public class ResponseGenerator {
  
      private final DepartmentsRepository departmentsRepository;
      private final LectorsRepository lectorsRepository;
  ...
  </code></pre>
  <p><strong>Departments</strong></p>
  <pre><code>@Entity
  @NoArgsConstructor
  @Setter
  @Getter
  @ToString
  @Table(name = &quot;departments&quot;)
  public class Departments {
  ...
  </code></pre>
  <p><strong>Lectors</strong></p>
  <pre><code>@Entity
  @NoArgsConstructor
  @Setter
  @Getter
  @ToString
  @Table(name = &quot;lectors&quot;)
  public class Lectors {
  ...
  </code></pre>
  <p><strong>DepartmentsRepository</strong></p>
  <pre><code>@Repository
  public interface DepartmentsRepository extends CrudRepository&lt;Departments, Integer&gt; {
  ...
  </code></pre>
  <p><strong>LectorsRepository</strong></p>
  <pre><code>@Repository
  public interface LectorsRepository extends CrudRepository&lt;Lectors, Integer&gt; {
  ...
  </code></pre>
  <p><strong>UniversityManagerSpringBootApplication</strong></p>
  <pre><code>@SpringBootApplication
  @AllArgsConstructor
  public class UniversityManagerSpringBootApplication implements CommandLineRunner {
  
      private ResponseGenerator responseGenerator;
  
      public static void main(String[] args) {
          SpringApplication.run(UniversityManagerSpringBootApplication.class, args);
      }
  
      @Override
      public void run(String... args) throws Exception {
  ...
  </code></pre>
  <p><strong>DepartmentsRepositoryTest</strong> (caused error)</p>
  <pre><code>@DataJpaTest
  class DepartmentsRepositoryTest {
  
      @Autowired
      private DepartmentsRepository departmentsRepository;
  
      @Test
      void injectedComponentIsNotNull(){
          assertNotNull(departmentsRepository);
      }
  ...
  </code></pre>