简体   繁体   English

错误java.lang.NoSuchMethodError

[英]Error java.lang.NoSuchMethodError


SOLVED 解决了


I'm using DTO to map my DB to a Java object. 我正在使用DTO将数据库映射到Java对象。

I had an error like this doku.eds2.dto.Transaction.getListedStatus()Ljava/lang/Character; 我遇到了这样的错误: doku.eds2.dto.Transaction.getListedStatus()Ljava/lang/Character;

I have checked my Transaction.java file, it contains the getListedStatus() method. 我已经检查了Transaction.java文件,其中包含getListedStatus()方法。

@Column(name="listed_status", length=1)
public Character getListedStatus() {
    return this.listedStatus;
}

public void setListedStatus(Character listedStatus) {
    this.listedStatus = listedStatus;
}

and also my table contains this field : 而且我的表包含此字段:

          Column           |            Type             | Modifiers 
listed_status              | character(1)                | 

How can I fix this error? 如何解决此错误?

Thank in advance. 预先感谢。

This sort of error often happens if you have two different versions of a class, one with the method and one without. 如果您有一个类的两个不同版本,一个有方法,一个没有方法,则经常会发生这种错误。 If the one without the method ends up in the classpath earlier than the one with, then you will get an error like this. 如果不使用该方法的代码比使用该方法的代码早出现在类路径中,那么您将得到这样的错误。

Make sure that your classpath does not contain any other classes of the type "doku.eds2.dto.Transaction". 确保您的类路径不包含“ doku.eds2.dto.Transaction”类型的任何其他类。 If you're in Eclipse, you can do this by pressing Ctrl-Shift-T and entering the class name into the search. 如果您使用的是Eclipse,则可以通过按Ctrl-Shift-T并在搜索中输入类名来实现。 If you get multiple matches, you probably have a class path or dependency problem. 如果获得多个匹配项,则可能是类路径或依赖性问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM