今天在写Spring Data JPA的时候出现了这样一个问题
Null return value from advice does not match primitive return type for: public abstract boolean
详细报错:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Apr 06 23:33:45 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
Null return value from advice does not match primitive return type for:
public abstract boolean com.gxuwz.assistant_demo.dao.LoginRepositoryDao.findByUserIdAndPasswordAndRoleId(java.lang.String,java.lang.String,java.lang.Integer)
问题如下:
因为sql语句查询的是userid 有的时候会查询到即返回一个String类型的数据,如果查不到就会返回一个null,而boolean不能接收null所以抛出异常
正确代码如下: