【错误记录】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 元对象协议与元编
- 下一篇: 【错误记录】GitHub 网站和仓库无法