title: spring boot,No qualifying bean of type found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency
body: <pre><code>@Controller
  @EnableAutoConfiguration
  public class ControllerShowInfo 
  {
      @RequestMapping("/")
      public String rawPage()
      {
          return "rawPage";
      }
  
      @Autowired
      stockreviewsRepositoryDao repository;
  
      @RequestMapping("/getBaseInfo")
      @ResponseBody
      public JSONArray getReviewsInfo()
      {
          JSONArray jsonArray = new JSONArray();
          for (stockreviewsBean reviewBean : repository.findAll()) 
          {
              jsonArray.put(reviewBean);
              System.out.println(reviewBean.getTitle());
          }
          return jsonArray;
      }
      public static void main(String[] args) throws Exception 
      {
          SpringApplication.run(ControllerShowInfo.class, args);
      }
  }
  </code></pre>
  
  <p>this is controller layer.</p>
  
  <pre><code>public interface stockreviewsRepositoryDao extends CrudRepository&lt;stockreviewsBean,String&gt; 
  {
  }
  </code></pre>
  
  <p>this is Dao layer.
  when I run ControllerShowInfo.class. There is a problem as follows:</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllerShowInfo': Unsatisfied dependency expressed through field 'repository': No qualifying bean of type [com.yxzh.mapper.stockreviewsRepositoryDao] found for dependency [com.yxzh.mapper.stockreviewsRepositoryDao]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.yxzh.mapper.stockreviewsRepositoryDao] found for dependency [com.yxzh.mapper.stockreviewsRepositoryDao]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: </p>
  </blockquote>
  
  <p>but when I run another .class</p>
  
  <pre><code>@SpringBootApplication
  public class Application 
  {
      public static void main(String[] args) throws Exception 
      {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>and implement CommmandLineRunner</p>
  
  <pre><code>@Component
  public class DataInitialization implements CommandLineRunner{
  
      @Autowired
      stockreviewsRepositoryDao repository;
  
      @Override
      public void run(String... args) throws Exception 
      {
          System.out.println("-------------------------------");
          int count=0;
          for (stockreviewsBean reviewBean : repository.findAll()) 
          {
              count++;
              System.out.println(reviewBean.getTitle());
          }
          System.out.println(count);
      }
  }
  </code></pre>
  
  <p>It worked well. It really confused me.</p>