I have my config:
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
.
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
the following property must be added in the gradle.build file
processResources {
filesMatching("**/*.properties") {
expand project.properties
}
}
Additionally, if working with Intellij, the project must be re-imported.
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.
Ensure 'idm.url' is set in property file and the property file is loaded
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:
ApplicationContext
types handle resources without prefix)<context:property-placeholder>
mechanism)