在上下文创建期间,spring是否为懒豆解析属性占位符? [英] Does spring resolve property placeholders for lazy beans during context creation?

查看:58
本文介绍了在上下文创建期间,spring是否为懒豆解析属性占位符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像spring xml上下文文件这样的bean定义

I have a bean definition like spring xml context file

<bean id="idFilter" class="some.package.app.filter.IdFilter" lazy-init="true">
    <constructor-arg type="java.lang.String" value="${id.start}"/>
</bean>

spring在构建上下文时是否尝试解析属性 $ {id.start} ?

Does spring try to resolve the property ${id.start} while building context?

我假设由于 idFilter 是延迟加载的,因此在使用该bean之前,不会尝试使用属性 id.start 进行解析.

I would assume since idFilter is lazily loaded, the property id.start will not be tried for resolution till the bean is being used.

对吗?

推荐答案

在仔细调试代码之后,我发现在创建bean定义时,即使对于懒惰的bean,也可以解析占位符.

After carefully debugging the code, I found that placeholders are resolved even for the lazy beans while creating bean definitions.

请注意,bean定义不是bean实例化.

Please note, bean definitions are not bean instantiation.

因此,如果未找到占位符,则所有bean都会抛出错误,无论bean懒惰还是渴望

So, if the placeholder is not found, an error is thrown for all beans regardless of bean being lazy or eager

这篇关于在上下文创建期间,spring是否为懒豆解析属性占位符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆