我正在尝试在Grails 4中创建一个bean并将其指定为主要对象,就像我们可以在Spring中使用注解
@Bean
@Primary
public Employee TonyEmployee() {
return new Employee("Tony");
}
我们如何处理Grails 4?
最佳答案
您可以使用BeanBuilder DSL
即指定主要数据源
transactionManager(org.springframework.jdbc.datasource.DataSourceTransactionManager) { bean ->
dataSource = ref("dataSource")
bean.primary = true
}
https://docs.grails.org/4.0.1/guide/spring.html#theBeanBuilderDSLExplained
关于grails - 如何在Grails 4项目中指定主bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60064789/