解决Cause: java.lang.NoSuchMethodException: com.sun.springmvc.pojo.Items.<init>()问题

在debug调试代码:

Cause: java.lang.NoSuchMethodException: com.sun.springmvc.pojo.Items.<init>()
DEBUG [http-apr-8081-exec-8] - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.sun.springmvc.controller.ItemController.itemList()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.sun.springmvc.pojo.Items with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.sun.springmvc.pojo.Items.<init>()
DEBUG [http-apr-8081-exec-8] - Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.sun.springmvc.controller.ItemController.itemList()]: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.sun.springmvc.pojo.Items with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.sun.springmvc.pojo.Items.<init>()
DEBUG [http-apr-8081-exec-8] - Could not complete request
解决办法:

  • com.sun.springmvc.pojo.Items.<init>()

这句话的意味着:试图在没有任何参数的情况下调用构造函数。

所以添加默认构造函数应该可以解决此问题:

public Items() {
}

猜你喜欢

转载自blog.csdn.net/sunaxp/article/details/81132449