java - How to do arithmetic in Spring properties, with values from a properties file? -
example use-case: properties file passes in numeric value in millis, , want use in seconds.
your .properties file:
jdbc.timeout= 2000
your applicationcontext.xml currently
<bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <property name="driverclassname" value="com.mysql.jdbc.driver" /> <property name="url"value="jdbc:mysql://myserver/mydb" /> <property name="username" value="user" /> <property name="password" value="changeme" /> <property name="validationquery" value="select 1;"/> <property name="validationquerytimeout" value="${jdbc.timeout}" /> </bean>
you want validationquerytimeout value in seconds, how convert it?
if you're using spring 3.0 or later, can use property inside spel expression this:
<property name="validationquerytimeout" value="#{${jdbc.timeout}/1000}" />
Comments
Post a Comment