原文:使用mybatis报错:Mapper method 'com.xin.dao.BlogMapper.addBlog attempted to return null from a method with a primitive return type (int).

错误原因 分析 本次报错的原因在于sql语句未查询到数据,返回为null。而我们定义的dao层方法是返回为int,就会出现如下这样的提示:return null from a method with a primitive return type int . 试图从具有原始返回类型 int 的方法返回null Ingeter是int的包装类,int的初值为 ,Ingeter的初值为null 解决方 ...

2021-04-21 18:59 0 504 推荐指数:

查看详情

attempted to return null from a method with a primitive return type (int)

解决方法: 方法1:将boolean、int、long等基本数据类型改为封装数据类型,boolean封装数据类型为Boolean、int封装数据类型为Integer,根据个人项目逻辑,对返回值进行判断即可。方法2:使用MySQL种的IFNULL函数,IFNULL函数是MySQL控制流函数 ...

Tue Feb 25 23:36:00 CST 2020 0 2918
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM