类的方法在Grails应用程序之外使用

时间:2014-12-16 23:44:42

标签: java grails

Gails 2.4.4在Mac上运行java 7.0_25

我删除了$ HOME / .grails 在新目录中开始

  • grails create-app foo
  • cd foo
  • 的grails
  • 运行的应用程序
  • create-domain-class Newtest

为此类添加了一个String

package testapp

class Newtest {

String TestString

def index() {}

static constraints = {}
}

然后我将其添加到BootStrap

class BootStrap {

def init = { servletContext ->

    new Newtest(TestString: "testme").save()

}
def destroy = {
 }
}

停止应用内
清洁
运行应用

| Running Grails application
| Error 2014-12-16 16:20:34,822 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: Method on class [testapp.Newtest] 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 [testapp.Newtest] was used outside of a Grails application. If running in the context of a test using the mocking API or bootstrap Grails correctly.

一切都是默认的,我使用谷歌的例子来确保我已正确设置。

有人可以告诉我出了什么问题,或者这是某种错误吗?

0 个答案:

没有答案