grails 控制台在将脚本打开为 .groovy 后无法执行该脚本
我正在使用 grails 控制台来测试我的代码,因为我发现从 STS 高效运行基本单元测试的效率非常低。
无论如何,当我将代码剪切并粘贴到控制台时,它运行良好。但是,当我将代码片段保存为 .groovy 脚本,然后稍后重新打开它并尝试运行它时,它会失败,并出现一般情况:
groovy.lang.MissingPropertyException: No such property: xxx for class: yyy
如果我复制代码并粘贴到新窗口中,则脚本运行正常!
知道为什么会发生这种情况吗?
I am using the grails console to test my code as I'm finding it very unproductive to run even basic unit tests efficiently from STS.
Anyway, when I cut and paste the code into the console it runs fine. However when I save the code snippet as a .groovy script and then reopen it later and try and run it, it fails with a generic:
groovy.lang.MissingPropertyException: No such property: xxx for class: yyy
The script runs fine if I copy the code and paste into into a new window!
Any idea why this might be happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了这个问题,并想在这里更新,以防对其他人有用。
我的域对象之一称为:
并且我将 groovy 脚本保存为 HierarchyNode.grooy。
因此,当在控制台中执行以下代码时,它失败了:
但有以下例外:
重命名脚本以不与域对象冲突解决了该问题。
I discovered what was wrong with this and wanted to update here in case it useful for someone else.
One of my domain objects is called:
and I saved the groovy script as HierarchyNode.grooy.
As a result when the following code was executed in the console, it failed:
with this exception:
Renaming the script to not clash with the domain object resolved the issue.