英文:
Does spring resolve property placeholders for lazy beans during context creation?
问题
我有一个像Spring XML上下文文件中的Bean定义:
<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}
吗?
我认为,由于idFilter
是懒加载的,直到使用该Bean之前,属性id.start
不会被尝试解析。
这样对吗?
英文:
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>
Does spring try to resolve the property ${id.start}
while building context?
I would assume since idFilter
is lazily loaded, the property id.start
will not be tried for resolution till the bean is being used.
Is it right?
答案1
得分: 4
经过仔细调试代码后,我发现即使在创建Bean定义时也会解析懒惰加载的Bean的占位符。
请注意,Bean定义与Bean实例化不同。
因此,如果找不到占位符,无论Bean是懒惰加载还是急切加载,都会为所有Bean抛出错误。
英文:
After carefully debugging the code, I found that placeholders are resolved even for the lazy beans while creating bean definitions.
Please note, bean definitions are not bean instantiation.
So, if the placeholder is not found, an error is thrown for all beans regardless of bean being lazy or eager
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论