开发者

Setting values from a class to Spring context file

We usually define some beans with their properties in the Spring context file and write some setter methods in the class.

Let's say I want to do the opposite. I have开发者_如何学Go a bean in the context file and want to declare some properties from the class, or initialize values of declared properties in the context from the class. How do I do that?


You will need to define a BeanFactoryPostProcessor. Bean factory post processors have the ability to alter or add to the context before spring fully initializers.

For more information please see the spring manual chapter for this: Chapter 3


You could either the util Spring XML namespace util:property-path or a PropertyPathFactoryBean to reference a bean's property as value for a property.

Please note that the property you refer to does not need to be defined by Spring, it can be set in code, like your question suggests you want to do

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜