How to add Properties to an Application Context

后端 未结 4 1802
感情败类
感情败类 2020-12-15 20:18

I have a Standalone Application, this application calculates a value (Property) and then starts a Spring Context. My question is how can I add that calculated property to th

4条回答
  •  太阳男子
    2020-12-15 20:52

    If You are controlling the creation of ApplicationContext as in Your example than You can always add a BeanRegistryPostProcessor to add a second PropertyPlaceholderConfigurer into the context. It should have ignoreUnresolvablePlaceholders="true" and order="1" and resolve only the custom calculated properties using the Properties object. All other properties should be resolved by the PropertyPlaceholderConfigurer from the XML that should have order="2".

提交回复
热议问题