I was playing with the new Spring 3.1.0.M2 @PropertySource annotation.
In fact I was trying to migrate
Note that this code load 2 property files. 1 default, and 1 environment/profile specific derived from the system properties using ${com.google.appengine.runtime.environment}.Code:<context:property-placeholder location="classpath*:META-INF/config.properties,classpath*:META-INF/config-${com.google.appengine.runtime.environment}.properties" />
I already tried this with the @PropertySource({"classpath:/META-INF/config.properties", "classpath:/META-INF/config-${com.google.appengine.runtime.environment}.proper ties"}) annotation without any luck.
Next to that I was think how the container will react if I add multiple @ProperySource annotations to various @Configuration classes. If I would program this I would use the MutablePropertySources which supports this using addFirst(), addBefore() etc. methods. The @ProperySource only allows setting the location or locations.
E.g. I have
The config.properties file will contain all my properties which will be overridden by the config-Development or config-Production.properties (dependent on the runtime profile).Code:@Configuration @PropertySource("classpath:/META-INF/config.properties") public class PropertiesConfig { } @Configuration @Profile("Development") @PropertySource("classpath:/META-INF/config-Development.properties") public class DevelopmentPropertiesConfig { } @Configuration @Profile("Production") @PropertySource("classpath:/META-INF/config-Production.properties") public class ProductionPropertiesConfig { }
But off course the config-Development or config-Production.properties should take precedence over/override the config.properties.


Reply With Quote