因此我们可以在 datasource.groovy 文件中创建不同的环境设置。我们可以像这样将通用设置放在环境节点之外
dataSource {
pooled = false
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:h2:mem:devDb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb"
}
}
}
但是有没有办法让我们可以让某些环境共享一些属性,而其他环境共享一组不同的属性,例如在开发人员之间共享一组属性(在这种情况下是 Omar 和 Stringer):
dev_dataSource {
pooled = false
driverClassName = "oracle.jdbc.driver.OracleDriver"
username = "dev"
password = "dev"
}
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = "something"
}
environments {
omar {
dataSource {
dev_dataSource {
url = "jdbc:oracle:thin:@omardb.wire.com:1521:devl"
}
}
}
stringer {
dataSource {
dev_dataSource {
url = "jdbc:oracle:thin:@stringerdb.wire.com:1521:devl"
}
}
}
devint {
dataSource {
dbCreate = "create-drop"
url = "jdbc:h2:mem:devDb"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb"
}
}
}
提前致谢...