1

I have:

<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:config/common.properties</value>
            <value>classpath:config/env/${env}/environment.properties</value>
        </list>
    </property>
    <property name="ignoreResourceNotFound" value="true" />
    <property name="nullValue" value="@null" />
</bean>

What I'd like to do is a System.out.print all the key/value pairs of properties available when I'm in a *.java file.

kasdega
  • 18,396
  • 12
  • 45
  • 89
  • Check http://stackoverflow.com/questions/11415711/programmatic-access-to-properties-created-by-property-placeholder – user2953113 Sep 30 '15 at 22:15

1 Answers1

0

I've had the same question. I wanted to get all the property names available in the Environment. I resolved it by iterating through the various PropertySource components. Unfortunately, some of the PropertySource(s) do not expose the property names. For those you have to know the property name and access the values from the property names.

Here are the various PropertySource(s) that I found. (You can get the property names for the enumerable ones, but I haven't found a way for the others.)

// EnumerablePropertySource
MapPropertySource
ServletContextPropertySource
PropertiesPropertySource
SystemEnvironmentPropertySource
PortletConfigPropertySource
PortletContextPropertySource
ServletConfigPropertySource
CommandLinePropertySource
JOptCommandLinePropertySource
SimpleCommandLinePropertySource
CompositePropertySource
PropertiesPropertySource
MockPropertySource
ResourcePropertySource

// Other
PropertySource$StubPropertySource
RandomValuePropertySource
MutablePropertySources
AixNPanes
  • 1,170
  • 3
  • 14
  • 33