醉了,一般这个注入不都是在类顶上注入嘛,这个可好,跑到
ScAuthApplication 中去注入了。。搞了半天,也记录一下吧
这里先说一下,其实就是在启动类中,去配置:
package cn.gov.rongcheng.scauth;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@SpringBootApplication
public class ScAuthApplication {
//1........加上这个Bean注入这个就好了.
@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder(){ //这里注入了就可以了
&nbs

在SpringBoot应用中遇到启动时错误,问题出在BCryptPasswordEncoder的注入位置。通常这类注入应在类顶部,但此处错误地在ScAuthApplication启动类中配置。解决办法是在启动类中添加@Bean注解,创建BCryptPasswordEncoder实例,从而解决启动报错。
订阅专栏 解锁全文
1359

被折叠的 条评论
为什么被折叠?



