I found the documentation on this topic rather confusing, so here is my cheat-sheet:
If you store the Configuration-Keys in the Web.config:
<configuration> <configSections> <section name="MyConfigSection" type="System.Configuration.NameValueFileSectionHandler, System,Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> </configSection> <MyConfigSection> <add key="ParameterName" value="ParameterValue"/> </MyConfigSection> </configuration>
<objects ...> <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core"> <property name="ConfigSections" value="MyConfigSection"/> </object> <object id="SomePOJO" type="SomeType"> <property name="Foo" value="${ParameterName}"/> </object> </objects>
If you use more than one config section in the App.config / Web.config file, you will need to register all the sections in the Spring's PropertyPlaceholderConfigurer object by adding them to its ConfigSection property. The values should be separated by a comma.
Don't use web.config at all, define everything in in spring's object xml only:
<objects ...> <object id="appPropertyConfigurer" type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core"> <property name="MyConfigSection"> <name-values> <add key="Foo" value="ParameterValue"/> </name-values> </property> </object> <object id="SomePOJO" type="SomeType"> <property name="Foo" value="${ParameterName}"/> </object> </objects>
Comments
Choice 2: 'MyConfigSection'
Choice 2:
'MyConfigSection' node cannot be resolved for the specified context [Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer].
huh
That's strage... I'll take a closer look at this issue when I'm back from my vaccations. Perhaps I pasted something wrong or the API has changed over the time.