title: Application Failed to Start Spring Tool Suite
body: <p>I am creating a spring boot project from scratch and trying to run my project but it failed to start. I am getting below error:</p>
  <pre><code>    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
      
      ***************************
      APPLICATION FAILED TO START
      ***************************
      
      Description:
      
      Field users in com.example.demo.DataInitializer required a bean of type 'com.example.repository.UserDao' that could not be found.
      
      The injection point has the following annotations:
          - @org.springframework.beans.factory.annotation.Autowired(required=true)
      
      Action:
      
      Consider defining a bean of type 'com.example.repository.UserDao' in your configuration.
  </code></pre>
  <p>This is my UserDao (Repository):</p>
  <pre><code>package com.example.repository;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  import com.example.model.User;
  
  @Repository
  public interface UserDao extends JpaRepository&lt;User, Long&gt;{
      User findByEmail(String email);
      User findByStatus(int status);
  }
  </code></pre>
  <p>This is My DataInitializer file, that I am trying to run:</p>
  <pre><code>package com.example.demo;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.CommandLineRunner;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.security.crypto.password.PasswordEncoder;
  import org.springframework.stereotype.Component;
  
  import com.example.model.User;
  import com.example.repository.UserDao;
  
  @Component
  public class DataInitializer implements CommandLineRunner{
  
      @Autowired
      UserDao users;
      @Autowired
      private PasswordEncoder passwordEncode;
      @Override
      public void run(String... args) throws Exception {
          //System.out.println(&quot;Running spring boot demo application&quot;);
          this.users.save(User.builder().email(&quot;example@gmail.com&quot;).phone(&quot;1234567890&quot;)
                  .username(&quot;Example Name&quot;).userid(10001L).build());
      }
  }
  </code></pre>