Could not resolve Spring property placeholder
You may have more than one org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
in your application. Try setting a breakpoint on the setLocations
method of the superclass and see if it's called more than once at application startup. If there is more than one org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
, you might need to look at configuring the ignoreUnresolvablePlaceholders
property so that your application will start up cleanly.
Your property file location is classpath:idm.properties
This is rather unusual, it means that idm.properties
must be located either at the top level of WEB-INF/classes
or at the top-level of one of the jars inside WEB-INF/lib
. Usually it's good practice to either use a dedicated folder for properties or keep them close to the context files that use them.
So my suggestion is this: Is your properties file perhaps next to your context file? If so, it's not on the classpath (see this question: Is WEB-INF in the CLASSPATH?).
The classpath:
prefix maps to a ClassPathResource
, but you probably need a ServletContextResource
, and you'll get that from a WebApplicationContext
using the syntax without prefix:
<context:property-placeholder location="idm.properties" />
Reference:
-
The
ResourceLoader
(describes how differentApplicationContext
types handle resources without prefix) -
The
PropertyPlaceholderConfigurer
mechanism
(describes the<context:property-placeholder>
mechanism)
It's definitely not a problem with propeties file not being found, since in that case another exception is thrown.
Make sure that you actually have a value with key idm.url
in your idm.properties
.
I still believe its to do with the props file not being located by spring. Do a quick test by passing the params as jvm params. i.e -Didm.url=....
make sure your properties file exist in classpath directory but not in sub folder of your classpath directory. if it is exist in sub folder then write as below classpath:subfolder/idm.properties