title: Can't @Autowire repository interface Spring Boot
body: <p>The problem I'm facing is about <code>@Autowire</code> the repository interface (UserRepository in my case), I don't know why, but the <code>@Autowire</code> is failing.</p>
  
  <p><code>UserController</code> class calls a <code>@Service</code> class and this one calls a <code>@Component</code> (DAO class), the DAO class is <code>@Autowiring</code> the <code>@Repository</code>.</p>
  
  <p><strong>Spring boot main</strong></p>
  
  <pre><code>package com.leagueofsummoners;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
  import org.springframework.boot.context.embedded.ErrorPage;
  import org.springframework.boot.orm.jpa.EntityScan;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  import org.springframework.http.HttpStatus;
  
  import com.leagueofsummoners.persistence.interfaces.UserRepository;
  
  @SpringBootApplication
  public class LeagueofsummonersApplication {
      public static void main(String[] args) {
          SpringApplication.run(LeagueofsummonersApplication.class, args);
      }
  
      @Bean
      public EmbeddedServletContainerCustomizer containerCustomizer() {
          return (container -&gt; {
              ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
              ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
              ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
  
              container.addErrorPages(error401Page, error404Page, error500Page);
          });
      }
  }
  </code></pre>
  
  <p><strong>DTO CLASS (Entity)</strong></p>
  
  <pre><code>@Entity(name = "user")
  @Table(name = "users")
  public class UserDTO implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @Column(name = "id_user")
  private Long idUser;
  
  @Column(nullable = false, name = "summoner_name")
  private String summonerName;
  @Column(nullable = false)
  private String username;
  @Column(nullable = false)
  private String password;
  @Column(nullable = false)
  private String email;
  @Column(nullable = false)
  private String avatar;
  @Column(nullable = false)
  private String firma;
  @Column(nullable = false, name = "permission_level")
  private PermissionLevels permissionLevel;
  
  public UserDTO() {
  }
  </code></pre>
  
  <p><strong>Repository interface</strong></p>
  
  <pre><code>import org.springframework.data.domain.Page;
  import org.springframework.data.domain.Pageable;
  import org.springframework.data.repository.Repository;
  
  import com.leagueofsummoners.model.dto.UserDTO;
  
  @org.springframework.stereotype.Repository
  public interface UserRepository extends Repository&lt;UserDTO, Long&gt; {
  
      Page&lt;UserDTO&gt; findAll(Pageable pageable);
  
      UserDTO findByUsernameIgnoringCase(String username);
  
      UserDTO findByIdUser(int idUser);
  }
  </code></pre>
  
  <p><strong>DAO class (this one failing when autowiring repository class)</strong></p>
  
  <pre><code>@Component
  public class UserDAO{
  
      @Autowired
      private UserRepository userRepository;
  
      public UserDTO findByUsernameIgnoringCase(String username) {
          return this.userRepository.findByUsernameIgnoringCase(username);
      }
  }
  </code></pre>
  
  <p><a href="https://justpaste.it/t4av" rel="nofollow">Here's a link with the log of the console</a></p>