Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
grails为什么不通过引导填充数据_Grails_Gorm_Bootstrapping - Fatal编程技术网

grails为什么不通过引导填充数据

grails为什么不通过引导填充数据,grails,gorm,bootstrapping,Grails,Gorm,Bootstrapping,我有下面的引导类 import shoppingsolutionproject.Category; import shoppingsolutionproject.Item class BootStrap { def dataSource def init = { servletContext -> new Category(description: 'Car').save() new Category(description: 'Tru

我有下面的引导类

import shoppingsolutionproject.Category;
import shoppingsolutionproject.Item

class BootStrap {

    def dataSource

    def init = { servletContext ->
        new Category(description: 'Car').save()
        new Category(description: 'Truck').save()
        new Item(productNumber:1, name:"First Product", description: "This is the first product I'm adding for testing",
                 shippingCost: 4.99, url: '/first', retailPrice: 19.99, salePrice: 16.99, category: 'Car').save()
        new Item(productNumber:2, name:"Second Product", description: "This is the second product I'm adding for testing",
                shippingCost: 4.99, url: '/second', retailPrice: 19.99, category: 'Truck').save()
        new Item(productNumber:3, name:"First/Second Product", description: "This is the first/second(so third) product I'm adding for testing",
                shippingCost: 4.99, url: '/second', retailPrice: 17.99, category: 'Truck').save()
    }
    def destroy = {
    }
}

但是,当我启动grails时,我没有预先填充类别或项目。。。知道原因吗?

您很可能有验证错误

验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)


这将向您展示许多由于验证错误而失败的事情

您很可能有验证错误

验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)


这将向您展示许多由于验证错误而失败的事情

您很可能有验证错误

验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)


这将向您展示许多由于验证错误而失败的事情

您很可能有验证错误

验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)


这将向您展示许多由于验证错误而失败的事情

很可能您有验证错误。验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)
。这应该会告诉你很多由于验证错误而失败的东西。@Joshuamore你是对的,我使用字符串“Car”作为类别,而不是我创建的类别对象。我们不使用“谢谢”或“感谢任何帮助”或签名。请参见“.BTW,它是“提前感谢”,而不是“提前感谢”。很可能您有验证错误。验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)
。这应该会告诉你很多由于验证错误而失败的事情。@Joshuamore你是对的,我使用字符串“Car”作为类别而不是我创建的类别对象。类似论坛网站,我们不使用“谢谢”或“感谢任何帮助”或签名。请参阅。顺便说一句,这是“提前感谢”,而不是“提前感谢”。很可能你有验证错误。验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)
。这应该会告诉你很多由于验证错误而失败的东西。@Joshuamore你是对的,我使用字符串“Car”作为类别,而不是我创建的类别对象。我们不使用“谢谢”或“感谢任何帮助”或签名。请参见“.BTW,它是“提前感谢”,而不是“提前感谢”。很可能您有验证错误。验证这一点的最快方法是将
failOnError:true
添加到
.save()
中,如下所示:
.save(failOnError:true)
。这应该会告诉你很多由于验证错误而失败的事情。@Joshuamore你是对的,我使用字符串“Car”作为类别而不是我创建的类别对象。类似论坛网站,我们不使用“谢谢”或“感谢任何帮助”或签名。请参阅。顺便说一句,这是“提前感谢”,而不是“提前感谢”。