tags:

views:

20

answers:

1

Hi, i have a properties folder and inside of ti contains my jdbc.properties file.

the problem is that i am unable to load it succesfuly as it always complains that it cannot locate the file.

i have the file currently sitting in the roo directopry fo WEB-INF. when i build and compile my spring mvc it does throw any exceptions but as soon as i load the beans from my code using new ClassPathXmlApplicationContext it fails and says it cannot locate my properties file??

here is how my beans look like:

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
        <property name="locations"> <list> <value>/properties/jdbc.properties</value> 
        </list> </property> </bean> 

<bean id="dataSource1" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
        <property name="driverClassName" value="${database.driver}" /> <property 
        name="url" value="${database.url}" /> <property name="username" value="${database.user}" 
        /> <property name="password" value="${database.password}" /> </bean>

here is a pic of my project structure at present:

alt text

A: 

You can put the properties files in root of classpath. And use like below.

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
        <property name="locations"> <list> <value>classpath:jdbc.properties</value> 
        </list> </property> </bean>
Jaydeep
root of classpath i.e inside th src directory?
jonney
Yes. But recommended structure is to separate properties files in separate folder e.g. resources. War package structure shown here (http://www.javaworld.com/javaworld/jw-12-2005/jw-1205-maven.html) for Maven is good example.
Jaydeep