service.SecurityServiceImpl中的字段authenticationManager需要类型为'org.springframework.security.authentication.AuthenticationManager'的bean

贾加德什P

我是Spring Boot的新手,正在尝试实现从该链接中学到的一切:login-registration-feature我的目标是建立用户登录和注册功能,但是我遇到了以下错误:

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

Description:

Field authenticationManager in com.x.assignment.auth.service.SecurityServiceImpl required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.

我的文件夹结构和代码与链接中提到的相同。但无法弄清楚为什么@AutoWired无法正常工作。请帮我。谢谢。

德米特里·爱纳什(Dmitry Ionash)

在配置类中WebSecurityConfig直接添加bean:

@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章