无法将DaoAuthenticationConfigurer应用于已构建的对象

无法将DaoAuthenticationConfigurer应用于已构建的对象,第1张

无法将DaoAuthenticationConfigurer应用于已构建的对象

我花了两天时间,但我相信我终于解决了这个问题。在我的

SecurityConfiguration
课堂上,我有以下方法

@Configuration@EnableWebMvcSecurity@EnableGlobalMethodSecurity(jsr250Enabled=true, prePostEnabled=true)public class SecurityConfiguration extends WebSecurityConfigurerAdapter {    @Autowired    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {        auth.userDetailsService(authenticationService);    }}

configureGlobal
用一种
configure
方法代替了该方法:

    @Override    public void configure(AuthenticationManagerBuilder auth) throws Exception {        auth.userDetailsService(authenticationService);    }

现在一切正常。

根据此答案的不同之处在于,使用

configureGlobal
将允许
AuthenticationManager
全局方法安全性或另一个HttpSecurity(WebSecurityConfigurerAdapter)。

如您在上面看到的,我同时启用了Web Mvc安全性和全局方法安全性。根据我的单元测试,两者都可以继续使用此更改,但是我的办公室在此存在一些关于此更改是否
正确 (即,如果它正确配置了全局方法安全性)或是否存在另一个问题的争论。解。

我们认为问题的根本原因是某种类型的Spring错误,可能是竞争情况。似乎不太可能,只有当我们向项目中添加一个空类时问题才显现出来,而该类的包或名称是什么都没有关系。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5501896.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存