错误截图:

org.apache.ibatis.binding.BindingException: Mapper method 'com.shop_demo.dao.AdminDAO.getAdminByNameAndPassword attempted to return null from a method with a primitive return type (int).at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:102)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)at com.sun.proxy.$Proxy8.getAdminByNameAndPassword(Unknown Source)at com.test.admin.admintest.get(admintest.java:55)at com.test.admin.admintest.main(admintest.java:74)

翻译过来是:

试图从具有基元返回类型(int)的方法返回空值。

解决办法:

将返回值boolean封装数据类型为Boolean、int封装数据类型为Integer。

当boolean、int、long等数据类型作为返回值时,用mybatis查询的结果null时,会出现错误,查了查才发现这些基本数据类型是不能定义为null的。
也就是说当数据库查询结果为null时,不能直接使用boolean、int、long等基本数据类型作为返回值。

Mybatis中的attempted to return null from a method with a primitive return type (int).异常相关推荐

  1. Mybatis:Mapper method attempted to return null from a method with a primitive return type (int)

    Mybatis中 Mapper method attempted to return null from a method with a primitive return type (int)错误 本 ...

  2. 关于mybatis的报错 attempted to return null from a method with a primitive return type (int)

    https://blog.csdn.net/kisscatforever/article/details/77801060 一.前言       在往常敲代码的时候没有留意过int和Integer的区 ...

  3. Mybatis异常错误:Mapper method attempted to return null from a method with a primitive return type (int)

    在mybatis搭建时出现错误:Mapper method attempted to return null from a method with a primitive return type (i ...

  4. error:attempted to return null from a method with a primitive return type (int)

    1,起因 今天老大让改bug,说有个模块数据提交不了,让我看看...检查服务器发现这个报错..attempted to return null from a method with a primiti ...

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

    一.场景和背景 工具:mybatis + pgsql dao代码: int selectMaxAgeBySex(String sex); 查询性别是女生的最大年龄 sql: <select id ...

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

    错误产生的场景 dao层接口如下 int getResourceDataNumsByTitle(String title); mapper.xml 中sql语句如下 <select id=&qu ...

  7. sql报错解决方案:attempted to return null from a method with a primitive return type (int)

    问题现象 idea执行查询数量语句控制台报错:attempted to return null from a method with a primitive return type (int). 解决 ...

  8. 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). 原来的代码 ...

  9. insertRole attempted to return null from a method with a primitive return type

    练习myBatis,向数据库插入一条数据,期望返回1,结果报错. 多次查找,结果是Mapper对应的xml文件中sql语句的节点写成select了,应该是insert

最新文章

  1. python 命令行参数-Python处理命令行参数
  2. Android PorterDuff.Mode
  3. swift4.0-11 类和结构体
  4. 整合Struts2、Spring、Hibernate构建J2EE应用
  5. C# 8.0 默认接口实现
  6. eclipse指定JDK版本启动,解决version XXX of the JVM is not suitable for this product.Version:XXX 问题
  7. XML 反序列化为Model
  8. git 服务器上新建项目
  9. skype显示未连接服务器,skype链接检测不到服务器
  10. php和java环境整合
  11. WEB三大攻击之—SQL注入攻击与防护
  12. matlab2014中GUI之菜单栏设计
  13. 如何用一台计算机控制多台计算机,怎么用一套鼠标键盘操作两台或多台电脑?...
  14. 高级JAVA开发 分布式系统部分
  15. html5 浏览器消息通知(Notification)
  16. 搜索引擎漫谈以及 Zinc 简介
  17. 计算机在小学英语中的应用,计算机在小学英语教学中的应用.doc
  18. Can You Really Backdoor Federated Learning
  19. 宝石排列 java_重新排列序列以最大化顺序差异,红宝石
  20. work-notes(15):私服报错401,Sonatype Nexus Repository Manager,may not contain non-url-safe chars如何解决?

热门文章

  1. 文巾解题 10. 正则表达式匹配
  2. MATLAB应用实战系列(四十四)-基于matlab的支持向量机分类、回归问题(附源码解析)
  3. Python3 实现批量图像数据增强(扩增)并复制xml标签文件【目标检测笔记】
  4. ModuleNotFoundError: No module named ‘lib.utils.cython_bbox‘
  5. #论文 《Deep Residual Learning for Image Recognition》
  6. 今日头条算法原理(全文)【转】
  7. Apache Flink 零基础入门【转】
  8. 99% 人看得懂的“熔断”以及最佳实践
  9. java.util.concurrent包详细分析--转
  10. Decorator pattern