Announcement Announcement Module
Collapse
No announcement yet.
PropertyPlaceholderConfigurer + System Properties Location Override Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyPlaceholderConfigurer + System Properties Location Override

    I know using xml configuration I can do something like this:
    Code:
        <bean id="placeholderProperties"
            class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location" value="classpath:${application.properties:override.properties}" />
            <property name="ignoreResourceNotFound" value="true" />
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
            <property name="ignoreUnresolvablePlaceholders" value="true" />
            <property name="order" value="1" />
        </bean>
    ...where the location value can be application.properties or be overwritten via a system property (-Doverride.properties=blah).

    How can I do this in straight code so I can use annotations in place of the xml version?
    Code:
      @Bean
      public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
        PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
        ppc.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE");
        ppc.setIgnoreResourceNotFound(true);
        ppc.setIgnoreUnresolvablePlaceholders(true);
        ppc.setLocation(?????);
        return ppc;
Working...
X