Apache Groovy——java.lang.NoSuchMethodError: x.x.x: method <init>()V not found

Original address: Apache groovy — Java. Lang. nosuchmethoderror: x.x.x: method() V not found 🙃)

Problem description

During the execution of groovy code, the following error occurred:

ava.lang.NoSuchMethodError: com.lispstudio.model.TeamLispstudio: method <init>()V not found

Cause of the problem

After inheriting the parent class, the constructor of the parent class is not called.

resolvent

There are two solutions: 1) call the same constructor as the parent class; 2) Use 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")

Using inheritconstructors annotation

class Creature {
    Creature (String feature) {}

Read More: