1. Error record
function
class Student1 {
}
Groovy code will report an error;
Error message:
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>
2. Problem analysis
Only groovy code that meets the following requirements can run:
With main function
test case, used as JUnit test or extended GroovyTestCase
Thread related and implements the runnable interface
It is compatible with the registered script running program
Groovy code in other cases cannot be run;