【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )
生活随笔
收集整理的这篇文章主要介绍了
【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
文章目录
- 一、错误记录
- 二、问题分析
一、错误记录
运行
class Student1 { }Groovy 代码 , 会报错 ;
报错信息 :
groovy.lang.GroovyRuntimeException: This script or class could not be run. It should either: - have a main method, - be a JUnit test or extend GroovyTestCase, - implement the Runnable interface, - or be compatible with a registered script runner. Known runners:* <none>二、问题分析
只有符合如下要求的 Groovy 代码可以运行 :
-
有 main 函数 ;
-
测试用例 , 作为JUnit测试或扩展GroovyTestCase ;
-
线程相关 , 实现Runnable接口 ;
-
与注册的脚本运行程序兼容 ;
其它情况的 Groovy 代码 , 均不可运行 ;
总结
以上是生活随笔为你收集整理的【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 【Groovy】MOP 元对象协议与元编
- 下一篇: 【Git】将 GitHub 工程设置为私