개발/에러 해결

Spring Security no instance(s) of type variable(s) exist so that UserService conforms to UserDetailsService 에러

슥혁 2021. 6. 18. 09:57

Spring Security를 이용한 로그인처리를 구현하던 도중 만나게 된 에러입니다.

 

 

no instance(s) of type variable(s) exist so that UserService conforms to UserDetailsService

 

자세히 보니 userService에 UserDetailsService를 상속받지 않고 그냥 SecurityConfig에 권한 검증 설정만 해둬서 생긴 문제였습니다..

 

 

바로 상속받고 구현해줬습니다.

 

 

 

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserEntity userEntity = userRepository.findByEmail(username);

        if(userEntity == null)
            throw new UsernameNotFoundException(username);

        return new User(userEntity.getEmail(), userEntity.getPassword(),
                true, true, true, true,
                new ArrayList<>());
    }

 

 

완료해주면 정상적으로 돌아갑니다.