I have a typical eclipse based web-app structure project.I coded for backend for the application and wanted to test it.I am using spring IOC and hibernate in the backend.So , all the xml and properties file are located in WEB-INF.When I am trying to test the backend through a stand alone main method ,it is not able to find the properties file although the properties file and xml are loacted in the same folder i.e . WEB-INF.
Asked
Active
Viewed 1,122 times
0

Rajeev Akotkar
- 1,377
- 4
- 26
- 46
-
Probable cause is: outside a webapp "/WEB-INF" is a directory named `WEB-INF` at the root path (i.e. `/` under linux). As a workaround, it's possible to use multiple locations with the PPC – May 25 '15 at 17:47
-
sorry I didn't get your point – Rajeev Akotkar May 25 '15 at 18:22
1 Answers
0
You can move your database.properties
to /WEB-INF/classes/database.properties
, basically put it on the classpath, and access it as
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:database.properties" />
</bean>

Master Slave
- 27,771
- 4
- 57
- 55
-
I am trying to run the backend using main method,where in I cannot get ServletContext. – Rajeev Akotkar May 26 '15 at 00:45
-
oki, I've removed from the answer as it is not a viable solution for you. Placing the properties file on classpath and accessing it as a classpath resource should work for you, doesn't it? – Master Slave May 26 '15 at 08:10