'com.bootdo.YJ.dao.ColonelDao.removeMaxYeJi attempted to return null from a method with a primitive return type (int).
时间: 2024-04-01 11:34:46 浏览: 15
这个错误提示是因为 `com.bootdo.YJ.dao.ColonelDao.removeMaxYeJi` 方法的返回类型是原始数据类型 `int`,但是在方法中却尝试返回了一个 null 值,原始数据类型是不能保存 null 值的,所以会引发该异常。
要解决这个问题,你需要确保在 `com.bootdo.YJ.dao.ColonelDao.removeMaxYeJi` 方法中不会返回 null 值,或者将该方法的返回类型改为包装数据类型 `Integer`,因为包装数据类型可以保存 null 值。如果你确定该方法不应该返回 null 值,那么你需要检查代码逻辑,找出在何处导致了该方法返回了 null 值,并进行修复。
相关问题
Mapper method 'com.bootdo.YJ.dao.ColonelDao.removeMaxYeJi attempted to return null from a method with a primitive return type (int).
这个问题是因为在返回类型为基本数据类型 int 的方法中,返回值不能为 null。在你提供的代码中,方法 `removeMaxYeJi` 的返回类型是 int,但是该方法可能会返回 null,导致编译器报错。
解决这个问题的方法是,在方法中添加一个默认的返回值,比如返回 0 或者 -1,以表示该方法在出现异常时的默认返回值。例如:
```
public int removeMaxYeJi() {
// your code...
if (result == null) {
return 0; // or -1, or any other default value
}
return result;
}
```
attempted to return null from a method with a primitive return type (int).分析错误
这个错误通常发生在你定义了一个返回类型为 int 的方法,但是在方法中没有返回任何值,或者返回了 null 值。由于 int 是一个原始数据类型,它不能为 null,因此会出现编译错误。
要解决这个问题,你需要确保在方法中返回一个 int 类型的值,或者将返回类型改为 Integer 类型,这样就可以返回 null 值了。你可以检查一下你的方法中是否有缺少返回语句或者返回类型与方法定义不匹配的情况。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)