【问题标题】:Grails isn't saving domain classes in the propper databaseGrails 没有在 propper 数据库中保存域类
【发布时间】:2012-11-24 03:20:09
【问题描述】:

我有一个 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'
}
}

【问题讨论】:

    标签: mysql grails grails-2.0


    【解决方案1】:

    在您的域类中,它应该是mapping 而不是mappings

    static mapping = {
        datasource  'alumnos'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      相关资源
      最近更新 更多