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

Field authenticationManager in service.SecurityServiceImpl required a bean of type 'org.springframework.security.authentication.AuthenticationManager'

我是 Spring Boot 的新手,正在尝试实施我从中学到的一切 link: 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.

我的文件夹结构,代码与link中提到的相同。但无法弄清楚为什么 @AutoWired 不起作用。请帮我。谢谢。

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

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