mybatis返回int类型报错 return null from a method with a primitive return type (int).
来源:互联网 发布:sql怎么把数据库导入 编辑:程序博客网 时间:2024/05/19 08:40
SSM 框架,当mybatis返回int类型时,报一下错误:
代码如下:
会报错如下:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'com.jeeplus.modules..res.dao.UserDao.getWeekClass attempted to return null from a method with a primitive return type (int).
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.Java:894)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
解决方案,返回类型设置为封装类型Integer而不是基本类型int
service层如果需要int数据类型,可以自动从Integer进行转换, 当然有可能加入一些判断,比如Integer为Null,赋给int可以先转成0
修改service层,代码如下:
- mybatis返回int类型报错 return null from a method with a primitive return type (int).
- 【java】Mybatis返回int类型为空时报错 attempted to return null from a method with a primitive return type (int)
- mybatis -----attempted to return null from a method with a primitive return type (int)
- 关于attempted to return null from a method with a primitive return type (int).报错解决方案
- attempted to return null from a method with a primitive return type (int).
- attempted to return null from a method with a primitive return type (int)异常的解决
- MyBatis提示getFundBonus attempted to return null from a method with a primitive return type (double)
- Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
- 【报错】Cannot return from outside a function or method
- 报错:Cannot return from outside a function or method
- return *(int*)b-*(int*)a意思
- #include int inc(int a) { return(++a); } int multi(int*a,int*b,int*c) { return(*c=*a**b); }
- aop.AopInvocationException: null return value from advice does not match primitive return type for
- myBatis 返回 int 类型时,报 null 异常
- mybatis返回int类型报错
- myeclipse 10 加载新的项目报错Cannot return from outside a function or method
- Return multiple values from a method
- return confirm Cannot return from outside a function or method
- C++学习小记
- 智能硬件全新开发方式
- 详解Java反射各种应用
- centos 常用命令
- 接下落的金币小游戏
- mybatis返回int类型报错 return null from a method with a primitive return type (int).
- Android 系统apk编译源代码的时候如何引用android-support-v4.jar 在Android.mk
- iOS——清理Xcode的缓存
- mongoVUE中collections为空,即文件树无法展开问题的解决策略
- Exception sendto failed: EPIPE (Broken pipe)上传图片
- java的锁机制
- Packet for query is too large (1149 > 1024)
- 互联网公司招聘文案背后的惨痛真相 你被hr坑过吗?
- 2017.1.8_FASTBOOT刷机和TFTP下载的总结