Create a JPA entity to implement the UserDetails interface.
@ComponentpublicclassSimpleUserDetailsServiceImplimplementsUserDetailsService {privatestaticfinalLogger log =LoggerFactory.getLogger(SimpleUserDetailsServiceImpl.class);privateUserRepository userRepository;publicSimpleUserDetailsServiceImpl(UserRepository userRepository) {this.userRepository= userRepository; } @OverridepublicUserDetailsloadUserByUsername(String username) throwsUsernameNotFoundException {User user =userRepository.findByUsername(username);if (user ==null) {thrownewUsernameNotFoundException("username not found:"+ username); }log.debug("found by username @"+ username);return user; }}
Define a UserDetailsService, which can be detected by the newest Spring Security, there is no need to wire the UserDetailsService with AuthenticationManager in configuration file. Check the Upgrade to Spring Boot 1.4 for more details.