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

简单来说,要加一个非空的过滤

原代码:

  1. Map<String, List<Device>> deviceMap = deviceList.stream().collect(Collectors.groupingBy(Device::getIp));

增加一个非空判断

  1. Map<String, List<Device>> deviceMap = deviceList.stream()
  2. .filter(item-> StringUtils.isNotBlank(item.getIp())).collect(Collectors.groupingBy(Device::getIp));

就解决了

需要注意其他的地方会不会影响到

【错误】element cannot be mapped to a null key的更多相关文章

  1. Atitit. null错误的设计 使用Optional来处理null

    Atitit. null错误的设计 使用Optional来处理null 然后,我们再看看null还会引入什么问题. 看看下面这个代码: String address = person.getCount ...

  2. 错误:Cannot set property 'innerHTML' of null

    360浏览器代码编辑器里提示错误:Cannot set property 'innerHTML' of null 原因是代码执行时要调用的内容不存在

  3. 【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 ...

  4. 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 ...

  5. spring整合xfire出现Document root element "beans", must match DOCTYPE root "null"错误解决方案

    fire自带的包下有个spring1.2.6的jar包,而工程的jar包是2.0的. 解决方案: 1.将原配置文件的头schema方式换为DOCTYPE方式,原配置文件如下(非maven) <? ...

  6. 页面提交错误,页面间参数传递java.lang.NumberFormatException: null

    多次出现这样的错误,在点击一个按钮触发提交整个页面的事件时,总是报错,不止一次出现这样的错误了. 出现这种问题的分析: 1 我们从这个问题的本身来看,java.lang.NumberFormatExc ...

  7. 关于LayoutInflater的错误用法(警告提示:Avoid passing null as the view root)

    项目中用LayoutInflater加载xml布局一直飘黄警告,上网搜了搜发现没有解释明白的,到是找到了一篇外国的博文,但是竟然是英文...幸好以前上学时候的英语不是很差加上谷歌的辅助,简单翻一下!  ...

  8. 【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 ...

  9. innerHTML用法及错误:无法设置未定义或null引用的属性“innerHTML”解决

    在使用ActionCable时, app/assets/javascripts/channels/calladdresses.coffee: App.calladdress = App.cable.s ...

随机推荐

  1. centos 8 安装 SonarQube遇到的启动问题及解决方案

    查看当前centos操作系统的版本 cat /etc/redhat-release 执行结果: 第一步安装openjdk,版本可以根据自己安装sonarqube的版本而定: 安装过程可参见我的另一篇博 ...

  2. AcWing 1127. 香甜的黄油

    农夫John发现了做出全威斯康辛州最甜的黄油的方法:糖. 把糖放在一片牧场上,他知道 N 只奶牛会过来舔它,这样就能做出能卖好价钱的超甜黄油. 当然,他将付出额外的费用在奶牛上. 农夫John很狡猾, ...

  3. 1.3.6、通过Path匹配

    server: port: 8080 spring: application: name: gateway cloud: gateway: routes: - id: guo-system4 uri: ...

  4. Archive for required library:’ WebRoot/WEB-INF/Mytag.tld’in project ‘TagTest’ cannot be read or is not a valid ZIP file

    Description::部署tld文件时报错 我的解决方法: 右击(当前项目)->Build Path->Java Build Path ( Configure Build Path.. ...

  5. 华为高级研究员谢凌曦:下一代AI将走向何方?盘古大模型探路之旅

    摘要:为了更深入理解千亿参数的盘古大模型,华为云社区采访到了华为云EI盘古团队高级研究员谢凌曦.谢博士以非常通俗的方式为我们娓娓道来了盘古大模型研发的"前世今生",以及它背后的艰难 ...

  6. 使用Hugo框架搭建博客的过程 - 主题配置

    前言 博客部署完成后,恭喜你可以发表第一篇:Hello world!但是LoveIt这么好用的主题,不配置一番可惜了. 基本功能配置 主题配置最好参考已有的配置,比如LoveIt作者写的介绍,还有主题 ...

  7. Git submodule 拉取子模块

    $ git clone https://code.Xcode.com.client.git Cloning into 'vipkid-pc-client'... Username for 'https ...

  8. python numpy高效体现

    import numpy as np import time def python_sum(n): a=[i**2 for i in range(n)] b=[i**3 for i in range( ...

  9. 三、k8s集群可用性验证与调参(第一章、k8s高可用集群安装)

    作者:北京小远 出处:http://www.cnblogs.com/bj-xy/ 参考课程:Kubernetes全栈架构师(电脑端购买优惠) 文档禁止转载,转载需标明出处,否则保留追究法律责任的权利! ...

  10. hapv-一个可以播放,下载国内主流视频的播放器

    electron 开发的一个可以播放,下载国内主流视频的播放器.A player developed by electron that can play and download domestic m ...