1、How do I configure a bean like this using Spring DSL ?
<bean id="mailSession" class="javax.mail.Session" factory-method="getInstance"> <constructor-arg> <props> <prop key="mail.smtp.auth">true</prop> </props> </constructor-arg> <constructor-arg ref="smtpAuthenticator" /> </bean>
2、 To answer my own question it should look like this:
beans = {
def props = new Properties()
props.setProperty('mail.smtp.auth', 'true')
mailSession(javax.mail.Session, props, ref('smtpAuthenticator')) { bean ->
bean.factoryMethod = 'getInstance'
}
...
}
Note that using Properties makes the code less tidy than if the property accepted a Map.