Reputation: 26202
I'm trying to set org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
spring bean, I have jdbc.properties in src/main/config
.. when I put this file in src/main/resources
and put classpath:
in value my app deploys successfuly.
This works when jdbc.properties is located in src/main/resources
<property name="location" value="classpath:jdbc.properties" />
However I'm required to put any configuration inside src/main/config
, how do I point springs towards this location in the right way?
Upvotes: 6
Views: 36280
Reputation: 11
If it is a maven project, you can add
<resources>
<resource>
<directory>src/main/config</directory>
<filtering>false</filtering>
</resource>
<resources>
to you <build>
in your pom.xml
Upvotes: 1
Reputation: 22948
The right answer to this is given by @matt b ,
"What I am referring to is the fact that when you package the application, the config files are not packaged in a folder named src/main/config in the packaged file (jar/war/etc.). Therefore your answer only works when you run the application within the source code, or when src/main/config is in the classpath (which it is not by default). The correct prefix is to use classpath: or another location."
In this question :
Trying to setup externalizing properties in spring
Upvotes: 3
Reputation: 8934
This is a classpath issue, not a Spring issue. Add src/main/config to your classpath and it will work. In Eclipse, this means adding it to the project Build Path->Source.
Upvotes: 12