grails - 在grails中保存域对象

标签 grails gorm grails-domain-class bootstrapping

我无法域对象保存在 Windows 8.1 Centos 7 上的grails中。每当我尝试创建一个空域类并将其保存在BootStrap.groovy中时,在运行该应用程序后,我总是收到相同的错误消息:

Error |
2014-11-10 14:53:44,225 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the appl
ication: Method on class [com.test.Book] was used outside of a Grails application. If running in the context of a test
 using the mocking API or bootstrap Grails correctly.
Message: Method on class [com.test.Book] was used outside of a Grails application. If running in the context of a test
 using the mocking API or bootstrap Grails correctly.
    Line | Method
->>    5 | doCall                           in BootStrap$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    327 | evaluateEnvironmentSpecificBlock in grails.util.Environment
|    320 | executeForEnvironment . . . . .  in     ''
|    296 | executeForCurrentEnvironment     in     ''
|    262 | run . . . . . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1145 | runWorker                        in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                              in java.lang.Thread
| Error Forked Grails VM exited with error

我的网域类别:
package com.test

class Book {
    String name
    static constraints = {
    }
}

BootStrap.groovy:
import com.test.Book
class BootStrap {

    def init = { servletContext ->
        new Book(name: "My Book").save()
    }
    def destroy = {
    }
}

我尝试了grat的 2.4.3 2.4.4 版本。我的jdk版本是 1.7.0_71 (也尝试过jdk6和jdk8)。有趣的是,我在Ubuntu和OpenSuse上尝试了确切的步骤,并且成功地保存了对象。那么,可能是什么问题呢?

问候,

最佳答案

问题已经解决了。操作系统的语言包似乎有麻烦。我正在使用Windows和Centos的土耳其语语言包。现在,我将其更改为英文,问题已解决。

关于grails - 在grails中保存域对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26844623/

相关文章:

grails - MongoDB、Grails 和关系

grails - 用于项目的Web2py或Grails框架

grails - 将Grails域属性的defaultValue设置为Joda-Time Period.ZERO

grails - 从GrailsDomainClass grails获取mapWith静态域字段值

grails - 具有多个约束的gorm实体

grails - Grails 集成测试名副其实吗?

grails - Grails 中的用户通知

grails - 如何在grails中限制hasMany域域中的数量有限

multithreading - Grails 1.3.7- Multi-Tenancy 插件和多线程操作-线程无法访问租户

grails - 如何在Grails的选择框中显示父域字段