解决ibatis.binding.BindingException: Mapper method 'xxx.xxx.dao.xxxDao.update' has an unsupported

问题描述:

    service调用dao层方法时,出现以下错误,但是sql执行修改数据成功:

2018-06-03 13:34:46.772 [http-nio-8080-exec-10] DEBUG [org.springframework.web.servlet.FrameworkServlet.processRequest] - Could not complete request
org.apache.ibatis.binding.BindingException: Mapper method 'com.ray.dao.CountryDao.update' has an unsupported return type: class com.ray.entity.Country
	at org.apache.ibatis.binding.MapperMethod.rowCountResult(MapperMethod.java:109) ~[mybatis-3.4.1.jar:3.4.1]
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62) ~[mybatis-3.4.1.jar:3.4.1]
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) ~[mybatis-3.4.1.jar:3.4.1]
	at com.sun.proxy.$Proxy32.update(Unknown Source) ~[?:?]
	at com.ray.service.impl.CountryServiceImpl.update(CountryServiceImpl.java:43) ~[classes/:?]
	at com.ray.controller.CountryController.save(CountryController.java:76) ~[classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]


原因:这个是因为dao层的sql执行成功后,返回的类型出现问题。


解决:

    mapper文件中的update,delete,insert语句是不需要设置返回类型的,它们都是默认返回一个int,所以应该修改dao层接口方法


猜你喜欢

转载自blog.csdn.net/q343509740/article/details/80556065
今日推荐