当我使用Grails提供的Spring DSL时,可以执行构造函数注入。如果是这样,一个例子将不胜感激。使用Grails Spring DSL的依赖注入
如果构造函数注入是不可能的,有没有其他的方式可以注入spring bean而不需要依赖关系公共属性。在Java项目中使用Spring我能做到这一点
class Foo {
@Autowired
private Bar bar
}
它将自动装配的Bar
依赖通过名称或使用@Autowired
注解像你通常做键入
看到http://grails.org/doc/latest/guide/14.%20Grails%20and%20Spring.html#14.4%20The%20BeanBuilder%20DSL%20Explained – 2011-04-14 07:12:39
这工作很好,但为什么不'constructorArgs = ref(' someBean')'也有效? – raffian 2012-09-14 17:39:55