I am using PropertyPlaceholderConfigurer to load a property file in my application from that I reading the database details and replacing it dynamically in data source as shown below.
<bean id="configJdbcProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:config.properties
</value>
</property>
</bean>
<bean id="mysqlSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="${mysql.jdbc.url}" />
<property name="user" value="${mysql.jdbc.username}" />
<property name="password" value="${mysql.jdbc.password}" /> </bean>
The above code works fine as expected. Problem: If there is any space in the above said properties value will leads to application failure.
Ex: mysql.jdbc.username= root
Now in the above example there is a space before user name root because of which my application fails to connect to DB. I accept it is a human error but is there a way in spring to handle it automatically or by enabling some properties in spring.