java - 即使存在这样的方法,如何修复 java.lang.NoSuchMethodError,并且本地服务器中不会​​发生错误

标签 java spring tomcat8

我在 Spring MVC Web 应用程序中收到以下错误。

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.smartwcm.core.reservation.service.CrentalReservationService.saveOrUpdateReservation(Lcom/smartwcm/commons/reservation/to/CrentalReservationTO;)Lcom/smartwcm/commons/reservation/to/CrentalReservationTO;

在本地服务器中执行代码时没有任何问题。但是当代码部署到 QA 服务器时,我收到上述错误。

错误中指定的方法是:

public void saveOrUpdateReservation(CrentalReservationTO reservation) throws CrentalException 
    {
        crentalReservationDao.saveOrUpdateReservation(reservation);
    }

CrentalReservationTO 是:

public class CrentalReservationTO 
{
    public CrentalReservationTO() 
    {
        super();
    }

    private int reservationId;
    private String reservationStatus;
    private int userCreated;
    private int userModified;
    private Date createdTime;
    private Date updatedTime;
    private int userId;
}

当我开始收到错误时,添加了默认构造函数,但它并没有解决问题。

最佳答案

您发布的方法签名是

void saveOrUpdateReservation(CrentalReservationTO reservation)

但是从异常消息

saveOrUpdateReservation(Lcom/smartwcm/commons/reservation/to/CrentalReservationTO;)
Lcom/smartwcm/commons/reservation/to/CrentalReservationTO;

您的代码正在调用

CrentalReservationTO saveOrUpdateReservation(CrentalReservationTO reservation)

您可能更改了一个类,但没有重新编译所有依赖类。

关于java - 即使存在这样的方法,如何修复 java.lang.NoSuchMethodError,并且本地服务器中不会​​发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37165544/

相关文章:

java - 在 Java 中生成字母

java - 如何分析 .hprof 文件?

java - 在java中的Clip对象上添加sfx

java - spring boot 文件上传进度

java - Tomcat 9 响应慢

java - Eclipse 中的 Tomcat 错误 404 但它以前工作过

java图像颜色公式

spring - 扫描 PackagesToScan 时忽略一些类

Spring @Procedure 和 List 作为返回

eclipse - Tomcat with Eclipse : Made a copy of webapp and renamed, 上下文路径没有改变