org.springframework.security.core.userdetails.UserDetailsService that could not be found

‘org.springframework.security.core.userdetails.UserDetailsService’ that could not be found

 今天遇见个特别傻的问题,在启动springboot的启动器是出现以下错误
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-12 15:40:29.680 ERROR 6864 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'org.springframework.security.core.userdetails.UserDetailsService' that could not be found.

The following candidates were found but could not be injected:
	- Bean method 'inMemoryUserDetailsManager' in 'UserDetailsServiceAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.security.authentication.AuthenticationManager,org.springframework.security.authentication.AuthenticationProvider,org.springframework.security.core.userdetails.UserDetailsService,org.springframework.security.oauth2.jwt.JwtDecoder,org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector; SearchStrategy: all) found beans of type 'org.springframework.security.authentication.AuthenticationManager' authenticationManager


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.security.core.userdetails.UserDetailsService' in your configuration.


Process finished with exit code 1
这个问题十分简单该实现类没有受到spring的管理 ,来看看 咋的代码
/**
 *  @author: yzy
 *  @Date: 2020/6/12 14:27
 *  @Description: 用户登录认证信息查询
 */

public class UserDetailServiceImpl implements UserDetailsService {

    @Resource
    private IUserService userService;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
在该类的上面应该写一个@Service的注解,为什么要加上这个注解呢,因为如果一个类带了@Service注解,该类将
自动注解到spring容器。
/**
 *  @author: yzy
 *  @Date: 2020/6/12 14:27
 *  @Description: 用户登录认证信息查询
 */
@Service
public class UserDetailServiceImpl implements UserDetailsService {
在启动项目:就好使了

org.springframework.security.core.userdetails.UserDetailsService that could not be found_第1张图片

你可能感兴趣的:(org.springframework.security.core.userdetails.UserDetailsService that could not be found)