I am using @PropertySource
in my datasource configuration file to get property files located on classpath. Below is my project structure.
I believe I can do it in two ways:
src
folder and add them there. As src
folder is already included in the classpath in eclipse, following should work. @PropertySources({ @PropertySource("classpath: com/spring/property/general.properties"), @PropertySource("classpath: com/spring/property/hibernate.properties") })
resources
folder and add it to the classpath and following should work @PropertySources({ @PropertySource("classpath: general.properties"), @PropertySource("classpath: hibernate.properties") })
In my case neither of the two is working. Being an intermediate java developer this still confuses me. Can anybody guide me in the right direction. And also how we can configure classpath resources for Spring in a production environment.
EDIT : I have changed my project structure to include properties file in src/java/resources
and I can see the resources
folder in build path. Still .properties
are not found by spring.
For anybody facing problem with usign .properties
files in Spring 4+, look at the thread below to match your setup with that of OP. Setup is all good except for a whitespace in configuration.
Not able to inject .properties file into Spring MVC 4.3 using @PropertySource
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.