报错背景

我在使用springboot做登录查询的时候报错了,我输入的是数据库中不存在的用户名与密码,返回值应该是null;


报错信息

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

解决方案

 把返回值类型改成Integer

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)

我来运行看看,是否真的有效

还是报错!

网上说把dao service返回值都改成Integer 

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)

 然后再control层里面

也是Integer接受值,这样写

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)

终于不报错了!太坎坷了!

相关文章: