What is Spring DSL equivalent for Spring XML "depends-on" attribute in Grails

Arc*_*her 7 grails

考虑一下我可以写resources.xml:

<bean id="beanOne" class="ExampleBean" depends-on="manager,accountDao"/>
Run Code Online (Sandbox Code Playgroud)

我会用Spring DSL编写它resources.groovy.怎么写depends-on指令?

Ian*_*rts 8

beanOne(ExampleBean) { bean ->
  bean.dependsOn = ['manager', 'accountDao']
}
Run Code Online (Sandbox Code Playgroud)

应该做你想做的事.大多数的<bean>属性具有bean.XXX等价物,包括init-method,destroy-method,factory-bean,factory-method,autowire-只需使用骆驼情况下,而不是连字符(例如bean.initMethod = "...").如果这不起作用,那么bean.beanDefinition将为您提供对实际Spring BeanDefinition对象的引用,以便您可以调用其他方法.