我有一个 grails (2.0) 应用程序,它需要从多个 MySQL 数据库中获取某些信息。看在上帝的份上,我无法将域类保存在正确的数据库中。
我的 Datasource.groovy 文件是这样的:
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/informacion_empleados_dev"
}
dataSource_signOn {
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/sign_on"
}
dataSource_administradores {
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/administradores"
}
dataSource_docentes {
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/docentes"
}
dataSource_alumnos {
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/alumnos"
}
}
我的每个域类都这样引用它们
class Alumno {
static constraints = {
matricula blank: false
nombres blank: false
apellidos blank: false
}
static mappings = {
datasource 'alumnos'
}
}