码迷,mamicode.com
首页 > 编程语言 > 详细

「Apache Groovy」- java.lang.NoSuchMethodError: x.x.x: method <init>()V not found @20210212

时间:2021-02-16 12:16:16      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:log   not   参考   使用   lan   gap   isp   文章   abc   

问题描述

在执行 Groovy 代码中,产生如下错误:

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

问题原因

在继承父类之后,没调用父类的构造函数。

解决方法

有两种解决方法:1)调用与父类相同的构造函数;2)使用 InheritConstructors 注解;

调用与父类相同的构造函数

class Creature {
    Creature (String feature) {}
}

class Humman extends Creature{
    Humman (String feature) {
		super(feature)
    }
}

new Humman("legs")

使用 InheritConstructors 注解

class Creature {
    Creature (String feature) {}
}

@groovy.transform.InheritConstructors
class Humman extends Creature{
}

new Humman("legs")

相关文章

「Groovy」- Unable to load extension class

参考文献

<init>()V not found when defining superclass constructor
InheritConstructors (groovy 2.4.9 API)


「Apache Groovy」- java.lang.NoSuchMethodError: x.x.x: method <init>()V not found @20210212

标签:log   not   参考   使用   lan   gap   isp   文章   abc   

原文地址:https://www.cnblogs.com/k4nz/p/14399288.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!