使用 Groovy Console,是否可以在类路径中重新加载更改的文件?
我经常想独立测试我在 Groovy 类中开发的方法,并使用控制台来执行此操作,例如:
groovyConsole -cp mygroovyfiles
但是我还无法弄清楚如何重新加载对我的 groovy 文件的更改,以便我可以更新文件并查看控制台中反映的结果。 “/Script/Add Directory to ClassPath”和“Script/Clear Script Context”不起作用。这可能吗?
I often want to test methods I'm developing in a Groovy class independently, and use the Console to do so, like:
groovyConsole -cp mygroovyfiles
However I have not yet been able to figure out how to reload changes to my groovy files so that I can update the files and see the results reflected in the Console. "/Script/Add Directory to ClassPath" and "Script/Clear Script Context" don't work. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不相信这在 groovyConsole 中是可能的。然而,groovysh 却是一个不同的故事。 groovysh 有一个 \l 命令,可以让您重新加载脚本。我不知道这对你是否有帮助,但这对我有用。一个会话看起来像这样......
I don't believe it is possible in the groovyConsole. The groovysh, however, is a different story. The groovysh has a \l command which lets you reload a script. I don't know if this helps you, but it works for me. A session would look like this...
您可以尝试在重新加载脚本之前清理缓冲区
You may try to clean your buffer before you reload the script