【错误】element cannot be mapped to a null key
element cannot be mapped to a null key的解决方法
报错:
ERROR [o.a.c.c.C.[.[.[/sa].[dispatcherServlet]] - Servlet.service() for servlet [dispatcherServlet] in context with path [/sa] threw exception [Request processing failed; nested exception is java.lang.NullPointerException: element cannot be mapped to a null key] with root cause
java.lang.NullPointerException: element cannot be mapped to a null key
简单来说,要加一个非空的过滤
原代码:
Map<String, List<Device>> deviceMap = deviceList.stream().collect(Collectors.groupingBy(Device::getIp));
增加一个非空判断
Map<String, List<Device>> deviceMap = deviceList.stream()
.filter(item-> StringUtils.isNotBlank(item.getIp())).collect(Collectors.groupingBy(Device::getIp));
就解决了
需要注意其他的地方会不会影响到
【错误】element cannot be mapped to a null key的更多相关文章
- Atitit. null错误的设计 使用Optional来处理null
Atitit. null错误的设计 使用Optional来处理null 然后,我们再看看null还会引入什么问题. 看看下面这个代码: String address = person.getCount ...
- 错误:Cannot set property 'innerHTML' of null
360浏览器代码编辑器里提示错误:Cannot set property 'innerHTML' of null 原因是代码执行时要调用的内容不存在
- 【redis】5.spring boot项目中,直接在spring data jpa的Repository层使用redis +redis注解@Cacheable直接在Repository层使用,报错问题处理Null key returned for cache operation
spring boot整合redis:http://www.cnblogs.com/sxdcgaq8080/p/8028970.html 首先,明确一下问题的场景 之前在spring boot整合re ...
- Jackson中处理map中的null key 或者null value 及实体字段中的null value
1.map中有null key时的序列化 当有null key时,jackson序列化会报 Null key for a Map not allowed in JSON (use a convert ...
- spring整合xfire出现Document root element "beans", must match DOCTYPE root "null"错误解决方案
fire自带的包下有个spring1.2.6的jar包,而工程的jar包是2.0的. 解决方案: 1.将原配置文件的头schema方式换为DOCTYPE方式,原配置文件如下(非maven) <? ...
- 页面提交错误,页面间参数传递java.lang.NumberFormatException: null
多次出现这样的错误,在点击一个按钮触发提交整个页面的事件时,总是报错,不止一次出现这样的错误了. 出现这种问题的分析: 1 我们从这个问题的本身来看,java.lang.NumberFormatExc ...
- 关于LayoutInflater的错误用法(警告提示:Avoid passing null as the view root)
项目中用LayoutInflater加载xml布局一直飘黄警告,上网搜了搜发现没有解释明白的,到是找到了一篇外国的博文,但是竟然是英文...幸好以前上学时候的英语不是很差加上谷歌的辅助,简单翻一下! ...
- 【Feign】@FeignClient相同名字错误 The bean 'xxx.FeignClientSpecification', defined in null, could not be registered
The bean 'xxx.FeignClientSpecification', defined in null, could not be registered. A bean with that ...
- innerHTML用法及错误:无法设置未定义或null引用的属性“innerHTML”解决
在使用ActionCable时, app/assets/javascripts/channels/calladdresses.coffee: App.calladdress = App.cable.s ...
随机推荐
- mysql过滤表中重复数据,查询相同数据的特定一条
待操作的表如下: p.p1 { margin: 0; font: 16px Menlo; color: rgba(0, 0, 0, 1) } span.s1 { font-variant-ligatu ...
- BUU mrctf shit
吐槽:去年没写出的题,现在终于可以上手了,昂哥nb 动调发现直接卡着不动了,怀疑是反调试,果然有好几处反调试 这里选择就不先nop了,先让程序跑起来,然后attach,在输入函数下面下个断点,atta ...
- leetcode156场周赛5206
思路分析: 1.两个数组,一个保存字符,一个保存字符出现次数 2.遍历一遍字符串,出现相同的字符,次数加一,且次数到k的话,那么就剔除,没到k,就次数加一.如果不同,就把它加入到字符的数组里面,对应次 ...
- Python 的上下文管理器是怎么设计的?
花下猫语:最近,我在看 Python 3.10 版本的更新内容时,发现有一个关于上下文管理器的小更新,然后,突然发现上下文管理器的设计 PEP 竟然还没人翻译过!于是,我断断续续花了两周时间,终于把这 ...
- 初步了解Unix系统的I/O模式
I/O模式 对于一次IO访问(以read举例),数据会先被拷贝到操作系统内核的缓冲区中,然后才会从操作系统内核的缓冲区拷贝到应用程序的地址空间. 当一个read操作发生时,它会经历两个阶段: 等待数据 ...
- 简单聊一下Uwsgi和Django的爱恨情仇
项目目录:/root/app Uwsgi的配置文件 [uwsgi] # Python扩展包安装的地方 pythonpath=/usr/local/src/python3/lib/python3.5/s ...
- Linux系统引导过程及排除启动故障
一.Linux操作系统引导过程二.系统初始化进程1.init进程2.Systemd3.Systemd单元类型三.排除启动类故障[1].修复MBR扇区故障(含实验过程)[2].修复GRUB引导故障●方法 ...
- C语言:警告提示及解决方法
#include <stdio.h> int main(){ struct{ char *name; //姓名 int num; //学号 int age; //年龄 char group ...
- python正则表达式应用
import re ab='''ms: [["", "\u7acb\u5373\u4e0b\u8f7d"], ["", "\u52 ...
- Easyui动态添加控件无法渲染 $.parser.parse()无效
本文链接:https://blog.csdn.net/huangbaokang/article/details/78367553动态添加easyui控件<input class="ea ...