- Spring Security 架构与源码分析以及基于Sprin
- Spring Security权限框架理论与实战(三)-数据库管
- Spring Security 自定义 Authenticati
- Spring Security 源码之 Authenticati
- spring security 自定义认证登录
- 01-Spring Security框架学习--入门(二)
- 高级框架第七天Spring Security:安全管理框架
- Spring Boot+Spring Security+Ajax
- 【Kotlin Spring Boot 服务端开发: 问题集锦】
- SpringBoot与Spring-Security的集成
Spring Security 自定义 AuthenticationProvider无法@Autowired问题
在AuthenticationProvider中使用@Autowired注入时始终报Null问题
找了半天发现应该在SecurityConfig配置类中
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
在设置AuthenticationProvider时应该使用@Bean的方式设置
@Bean
CustomAuthenticationProvider customAuthenticationProvider() {
return new CustomAuthenticationProvider();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(customAuthenticationProvider());
}
之前的错误的设置方式是:
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(new CustomAuthenticationProvider());
}
以上可以在实现AuthenticationProvider时自由的使用@Autowired了
网友评论