-
Is the properties file in the ROOT of the class directory (I assume you mean classes in the WEB-INF directory?). Else try changing classpath: to classpath:/ (although I thought that spring strips the leading slash).
Also make sure that all the keys are in the properties file and that they are correct (also check my spelling because I did it from the top of my head).
-
Still didn't get it.
Hello.
Re-taking this. Any help?
Thank you again, Marten.
But I still have this problem.
I know this has to be very simple. I am not getting to read from a properties file. (hibernate.properties)
In applicationContext.xml I have this:
Code:
<bean class="org.springframework.beans.factory.PropertyPlaceHolderConfigurer">
<property name="locations" value="classpath:./hibernate.properties" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="${hibernate.connection.username}" />
<property name="password" value="${hibernate.connection.password}" />
<property name="url" value="${hibernate.connection.url}" />
<property name="driverClassName" value="${hibernate.connection.driver_class}" />
<property name="initialSize" value="5" />
<property name="maxActive" value="20" />
</bean>
And in the hibernate.properties I have:
Code:
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/consulta
hibernate.connection.username=ElPiter
hibernate.connection.password=password
hibernate.dialect=org.hibernate.dialect.MySQLDialect
However, I am getting this error when creating context (starting up Tomcat Server):
Code:
GRAVE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Could not resolve placeholder 'hibernate.connection.username'
The properties file is in WEB-INF/classes. And the spelling is correct. As far as I checked it N-1 times ;)
Obviously something must be wrong. But I don't get what it is.
Would you take a new look?
Thanks, Pedro
-
Enable debug logging and see if the file gets read. If it isn't it isn't in the location you think it is...