Spring boot BCryptPasswordEncoder未作为spring boot starter安全性的一部分导入

Spring boot BCryptPasswordEncoder未作为spring boot starter安全性的一部分导入,spring-boot,password-encryption,password-hash,Spring Boot,Password Encryption,Password Hash,找不到bean BCryptPasswordEncoder,尽管我通过maven依赖项和spring引导启动程序安全性导入了它 我尝试使用BCryptPasswordEncoder进行密码哈希,但在启动项目时出现错误: 中构造函数的参数0 com.websystemque.springboot.controller.RestApiController需要一个 豆荚 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder'

找不到bean BCryptPasswordEncoder,尽管我通过maven依赖项和spring引导启动程序安全性导入了它

我尝试使用BCryptPasswordEncoder进行密码哈希,但在启动项目时出现错误:

中构造函数的参数0 com.websystemque.springboot.controller.RestApiController需要一个 豆荚 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' 那是找不到的

我正在使用spring boot,我只是在我的控制器中使用它,如:


@Autowired BCryptPasswordEncoder BCryptPasswordEncoder

@配置
类中添加BcryptPasswordEncoder bean。它不是自动申报的

@Bean
public PasswordEncoder passwordEncoder() {
    return new BCryptPasswordEncoder();
}
(可选)并像这样注入

@Autowired
private PasswordEncoder passwordEncoder;