groovy.lang.MissingMethodException - 保存 GORM

groovy.lang.MissingMethodException - Save GORM

我是 groovy grails 的新开发人员,我在数据库测试中有一个 table 命名用户。我使用 grails 成功登录到该数据库,但无法成功注册新用户。我已经使用 GORM 导入到数据库中,但是出现了一个奇怪的错误,我找不到任何可能的解决方案来解决这个问题。

我的域class

package com.example.ulu

import grails.persistence.Entity;

@Entity
class User {

    String userName
    String password
    String fullName


    static constraints = {

    }
}

控制器

def registeruser = { 

    User a = new User()
    a.fullName("John")
    a.userName("burak")
    a.password("1") 
    a.save()


}

插件和依赖项

dependencies {

        runtime 'mysql:mysql-connector-java:5.1.29'

        test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
        compile "javax.validation:validation-api:1.1.0.Final"
        compile "org.grails:grails-spring:2.4.5"
        compile "org.codehaus.groovy:groovy-all:2.4.5"
        runtime "org.hibernate:hibernate-validator:5.0.3.Final"

    }

    plugins {

        build ":tomcat:8.0.22"


        compile ":scaffolding:2.1.2"
        compile ':cache:1.1.8'
        compile ":asset-pipeline:2.1.5"
        runtime ":resources:1.2.14"


        runtime ":hibernate4:4.3.8.1"
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"
    }
a.fullName("John")
a.userName("burak")
a.password("1") 

这都是错误的。 Groovy 使用 JavaBean 表示法,属性-赋值必须如下所示:

a.fullName = "John"
a.userName = "burak"
a.password ="1"

a.setFullName "John"
a.setUserName "burak"
a.setPassword "1"

a[ 'fullName' ] = "John"
a[ 'userName' ] = "burak"
a[ 'password' ] ="1"