栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Autowired属性为null

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Autowired属性为null

依赖于a的bean的较早初始化

DataSource
绝对是问题所在。根本原因与Spring
Boot或自动配置无关,而是通过一个由包裹您的业务bean的方面来应用简单的老式鸡和蛋方法安全性
BeanPostProcessor
。一个bean只能发表一些初始化处理
非常
早。在这种情况下,进行
DataSource
注入还为时过早(实际上,实例化
@Configuration
需要的类
DataSource
为时过早,无法正确包装在
@Configuration
加工机械中,因此无法自动接线)。我的建议(只会使您与缺少相同之处
AuthenticationManager
)是将声明
GlobalMethodSecurityConfiguration
为嵌套类,而不是将其声明为嵌套类。
DataSource

在以下位置需要:


@EnableGlobalMethodSecurity(prePostEnabled = true)@Configurationprotected static class ActualMethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {    @Autowired    @Qualifier("aclDaoAuthenticationProvider")    private AuthenticationProvider aclDaoAuthenticationProvider;    @Autowired    @Qualifier("aclAnonymousAuthenticationProvider")    private AnonymousAuthenticationProvider aclAnonymousAuthenticationProvider;    @Autowired    @Qualifier("aclexpressionHandler")    private MethodSecurityexpressionHandler aclexpressionHandler;    @Override    protected void configure(AuthenticationManagerBuilder auth) throws Exception {        auth.authenticationProvider(aclDaoAuthenticationProvider);        auth.authenticationProvider(aclAnonymousAuthenticationProvider);    }    @Override    public MethodSecurityexpressionHandler createexpressionHandler() {        return aclexpressionHandler;    }

}

也就是说

RootMethodSecurityConfiguration
,将其粘贴到并
@EnableGlobalMethodSecurity
从该类中删除注释。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/382370.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号