database - groovy.lang.MissingMethodException-保存GORM

标签 database grails gorm

我是groovy grails的新开发人员,并且在数据库测试下有一个名为user的表。我通过使用grails成功登录了该数据库,但无法成功注册新用户。我已经使用GORM导入数据库,但是有一个奇怪的错误,我找不到任何可能的解决方案来解决此问题。

ERROR I GET

我的域类

package com.example.ulu

import grails.persistence.Entity;

@Entity
class User {

    String userName
    String password
    String fullName


    static constraints = {

    }
}

Controller
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"

关于database - groovy.lang.MissingMethodException-保存GORM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33105067/

相关文章:

unit-testing - Class.metaclass.static说不能在null上获得静态

java - 读取 CSV 文件并使用 Grails/Groovy 将结果放入 map 中

grails - ERR_TOO_MANY_REDIRECTS在grails中

grails - 如何删除Grails中的关联对象?

php - 将 unix_timestamp 插入 mysql 数据库

java - 编译时无法启动 Activity ComponentInfo : android. database.sqlite.SQLiteException : no such table ,

php - 如何使用以前从数据库 MySQLI 提交的数据预选下拉选项

php - 有人可以帮助我解决此错误消息吗?我无法弄清楚

grails - Weceem插件和Grails关于内容发布工作流程

hibernate - 在GGTS中映射一对多关系