Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring security配置多个WebSecurityConfigurerAdapter后,如何在service层获得AuthenticationManager实例? #27

Closed
mcyustc opened this issue Jun 30, 2021 · 1 comment

Comments

@mcyustc
Copy link

mcyustc commented Jun 30, 2021

@Override
protected void configure(AuthenticationManagerBuilder auth) {
    DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
    daoAuthenticationProvider.setUserDetailsService(userDetailsService);
    daoAuthenticationProvider.setPasswordEncoder(new BCryptPasswordEncoder());
    auth.authenticationProvider(daoAuthenticationProvider);
}

如果向若依一样注入bean会导致启动失败

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

所以这段代码只好删除。

那么如何在service层注入生效的AuthenticationManager呢?请大佬指点不胜感激

@yangzongzhuan
Copy link
Owner

这种问题和框架无关,可以自己去网上查询一下相关资料spring security配置多个实例

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants