找不到bean BCryptPasswordEncoder虽然我通过maven依赖和spring-boot-starter-security导入它
我尝试使用BCryptPasswordEncoder进行密码散列,但是当我启动项目时出现错误:
com.websystique.springboot.controller.RestApiController中构造函数的参数0需要一个无法找到的类型为'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder'的bean .
我正在使用spring-boot,我只是在我的控制器中使用它,如:
@Autowired BCryptPasswordEncoder bCryptPasswordEncoder;
1 回答
在
@Configuration
类中添加BcryptPasswordEncoder bean . 它不会自动声明 .(可选)并像这样注入 .