我在 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/