當(dāng)前位置:
首頁 >
【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )
發(fā)布時(shí)間:2025/6/17
57
豆豆
生活随笔
收集整理的這篇文章主要介紹了
【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
文章目錄
- 一、錯(cuò)誤記錄
- 二、問題分析
一、錯(cuò)誤記錄
運(yùn)行
class Student1 { }Groovy 代碼 , 會(huì)報(bào)錯(cuò) ;
報(bào)錯(cuò)信息 :
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 代碼可以運(yùn)行 :
-
有 main 函數(shù) ;
-
測(cè)試用例 , 作為JUnit測(cè)試或擴(kuò)展GroovyTestCase ;
-
線程相關(guān) , 實(shí)現(xiàn)Runnable接口 ;
-
與注冊(cè)的腳本運(yùn)行程序兼容 ;
其它情況的 Groovy 代碼 , 均不可運(yùn)行 ;
總結(jié)
以上是生活随笔為你收集整理的【错误记录】IntelliJ IDEA 编译 Groovy 报错 ( GroovyRuntimeException: This script or class could not be run. )的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Groovy】MOP 元对象协议与元编
- 下一篇: 【Git】将 GitHub 工程设置为私