title: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field 'userDetailsService'
body: <p>I'm trying to create a Spring Boot application which uses Spring Security and OAuth2 to authenticate via a database. I am trying to follow the GitHub examples of this repository ( <a href="https://github.com/TechPrimers/spring-security-db-example" rel="nofollow noreferrer">https://github.com/TechPrimers/spring-security-db-example</a> ) and now facing this error.</p>
  
  <p>The para-phrased StackTrace :</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsDervice': Unsatisfied dependency expressed through field 'usersRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional com.user.path.to.repository.UsersRepository.findByName(java.lang.String)! No property name found for type AccountUser!
  
  Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsDervice': Unsatisfied dependency expressed through field 'usersRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional com.user.path.to.repository.UsersRepository.findByName(java.lang.String)! No property name found for type AccountUser!
  
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional com.user.path.to.repository.UsersRepository.findByName(java.lang.String)! No property name found for type AccountUser!
  
  Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional com.user.path.to.repository.UsersRepository.findByName(java.lang.String)! No property name found for type AccountUser!
  
  Caused by: org.springframework.data.mapping.PropertyReferenceException: No property name found for type AccountUser!
  </code></pre>
  
  <p>Here are my classes:</p>
  
  <p><strong>CustomUserDetailsService</strong></p>
  
  <pre><code>  @Service("userDetailsDervice")
    public class CustomUserDetailsService implements UserDetailsService {
  
    @Autowired
    private UsersRepository usersRepository;
  
  
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
      Optional&lt;AccountUser&gt; optionalUsers = usersRepository.findByName(username);
  
      optionalUsers
              .orElseThrow(() -&gt; new UsernameNotFoundException("Username not found"));
      return optionalUsers
              .map(CustomUserDetails::new).get();
    }
  }
  </code></pre>
  
  <p><strong>UsersRepository</strong></p>
  
  <pre><code>@Repository
  public interface UsersRepository extends JpaRepository&lt;AccountUser, Integer&gt; {
      Optional&lt;AccountUser&gt; findByName(String username);
  }
  </code></pre>
  
  <p><strong>AccountUser</strong></p>
  
  <pre><code>@Entity
  @Table(name = "User")
  public class AccountUser {
  
  @Column(name = "title")
  private String title;
  
  @Column(name = "firstname")
  private String firstname;
  
  @Column(name = "lastname")
  private String lastName;
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "email")
  private String email;
  
  @Column(name = "password")
  private String password;
  
  @Column(name = "modified")
  private Date modified;
  
  @Column(name = "accessed")
  private Date accessed;
  
  /* ... getters and setters ....*/
  </code></pre>