Problem Description
In the execution of Groovy code, the following error is generated:
ava.lang.NoSuchMethodError: com.lispstudio.model.TeamLispstudio: method <init>()V not found
problem causes
After inheriting the parent class, the constructor of the parent class is not called.
Solution
There are two solutions: 1) call the same constructor as the parent class; 2) use the InheritConstructors annotation;
Call the same constructor as the parent class
class Creature { Creature (String feature) {} } class Humman extends Creature{ Humman (String feature) { super(feature) } } new Humman("legs")
Use InheritConstructors annotation
class Creature { Creature (String feature) {} } @groovy.transform.InheritConstructors class Humman extends Creature{ } new Humman("legs")
related articles
「Groovy」- Unable to load extension class
references
<init>()V not found when defining superclass constructor
InheritConstructors (groovy 2.4.9 API)