我无法将域对象保存在 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/