Configure a bean with factory using Spring DSL

阅读更多

1、How do I configure a bean like this using Spring DSL ?

    
        
            
                true
            
        
        
    

 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.

你可能感兴趣的:(Bean,Spring)