返回介绍

6.5.4 设置忽略依赖

发布于 2025-04-22 22:09:12 字数 646 浏览 0 评论 0 收藏

当 Spring 将 ApplicationContextAwareProcessor 注册后,那么在 invokeAwareInterfaces 方法中间接调用的 Aware 类已经不是普通的 bean 了,如 ResourceLoaderAware、ApplicationEventPublisher Aware 等,那么当然需要在 Spring 做 bean 的依赖注入的时候忽略它们。而 ignoreDependencyInterface 的作用正是在此。

//设置了几个忽略自动装配的接口

 beanFactory.ignoreDependencyInterface(ResourceLoaderAware.class);

 beanFactory.ignoreDependencyInterface(ApplicationEventPublisherAware.class);

 beanFactory.ignoreDependencyInterface(MessageSourceAware.class);

 beanFactory.ignoreDependencyInterface(ApplicationContextAware.class);

 beanFactory.ignoreDependencyInterface(EnvironmentAware.class);

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。