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

Mapper method ‘xxx‘ attempted to return null from a method with a primitive return type (int)_第1张图片报错情况:

Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'com.aqiuo.mapper.UserMapper.login attempted to return null from a method with a primitive return type (int).

报错原因:

 

  int login(@Param("account") String account,@Param("password") String password);

select 查询不到数据就会返回null ,但是int 是不接受null的,所以出现这个情况

解决方法:

将返回值改成Integer

 

Integer login(@Param("account") String account,@Param("password") String password);

Mapper method ‘xxx‘ attempted to return null from a method with a primitive return type (int)_第2张图片

你可能感兴趣的:(异常报错,数据库)