我正在阅读"Grails in Action"一书,我坚持介绍grails控制台的那一部分.从我的项目目录中,我输入"grails console"来打开一个控制台窗口,控制台甚至输出信息表明它正在编译类,但当我在控制台中键入它时:
new Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()
我收到此错误:
unable to resolve class Quote
at line: 1, column: 1
Run Code Online (Sandbox Code Playgroud)
Quote类存在于Quote.groovy中grails-app/domain/qotd/Quote.groovy
,我无法运行上述命令.
这里出了什么问题?
Jac*_*ack 45
在尝试实例化之前,您是否尝试导入包含域类的包?
import qotd.Quote
new Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()
Run Code Online (Sandbox Code Playgroud)
确保您还可以尝试指定完整的限定名称:
new qotd.Quote(author:'Larry Wall',content:'There is more than one method to our madness.').save()
Run Code Online (Sandbox Code Playgroud)
我正在阅读Grails in Action第二版(2.1.1)的MEAP,发现该解决方案已运行:
grails clean
grails console
Run Code Online (Sandbox Code Playgroud)
再次在groovy控制台中键入代码并运行
归档时间: |
|
查看次数: |
10465 次 |
最近记录: |