This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Environment.getProperty not returning property configured in .properties filePage Title Module

I have a properties file called indexClassConfig.properties located under META-INF/spring/. I am able to use the @Value annotation on a class member in order to retrieve a value from this properties file. However, if I try to retrieve a property using Spring's Environment abstraction, the keys are not found, but I know they exist. It seems the only PropertySources registered are the systemProperties and systemEnvironment.

In an @Configuration file, I have a String annotated with @Value("${configuredIndexClassNames}") which allows me to determine the configured index class names that I then lookup up in a database. That works just fine. The second line in the file shows configured key values for a key field named DOCUTYPE for the index class DSNDOCS.

This is an excerpt from a class where I attempt to lookup the value of "configuredKeyValues.DSNDOCS.DOCUTYPE" from the properties file. The IndexClass and KeyField instance are passed to findConfiguredKeyValues, which is where the lookup for the value happens. Environment is injected into this class, but the property isn't found.