Specify default property value as NULL in Spring
It is better to use Spring EL in such way
<property name="password" value="${email.password:#{null}}"/>
it checks whether email.password
is specified and sets it to null
(not "null"
String) otherwise
have a look at PropertyPlaceholderConfigurer#setNullValue(String)
It states that:
By default, no such null value is defined. This means that there is no way to express null as a property value unless you explictly map a corresponding value
So just define the string "null" to map the null value in your PropertyPlaceholderConfigurer:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="nullValue" value="null"/> <property name="location" value="testing.properties"/></bean>
Now you can use it in your properties files:
db.connectionCustomizerClass=nulldb.idleConnectionTestPeriod=21600
You can try use Spring EL.
<prop key="email.username">#{null}</prop>