I'm trying to get the PropertyPlaceholderConfigurer to work. I'm using Spring 1.2.2. My application context is as follows:
In WEB-INF/classes, I have a file called jdbc.properties:Code:<beans> <!-- property placeholder post-processor --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> </bean> <bean id="dataSource" autowire="no" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://${jdbc.host}/${jdbc.dbname}</value> </property> <property name="username"> <value>${jdbc.username}</value> </property> <property name="password"> <value>${jdbc.password}</value> </property> </bean> ...
...but, the properties don't seem to be substituted. I get the following errorCode:# The JDBC settings jdbc.username=devbox jdbc.password=devbox jdbc.dbname=devbox jdbc.host=localhost
...
I've read through other postings on similar topics, and I understand that the automatic substitution only occurs for an application context, not a bean factory. But since these definitions are defined in the application context (and being loaded by the serlvet container automatically, doesn't that imply that I'm using the application context?Code:WARN - JDBCExceptionReporter.logExceptions(71) | SQL Error: 0, SQLState: 08S01 ERROR - JDBCExceptionReporter.logExceptions(72) | Unable to connect to any hosts due to exception: java.net.UnknownHostException: ${jdbc.host}
Thanks for any help and enlightenment...


Reply With Quote