toMap - bug
原因:AttachmentInfoRespnse::getAssociateKeyId 作为键重复了,代码没有指定如何处理
//Duplicate key:错误代码
final Map<Long,String> keyIdWithPathMap = attachmentInfoResponse.stream().collect(Collections.toMap(AttachmentInfoRespnse::getAssociateKeyId, item -> Optional.of(item.getxxx()).orElse)))
//解决代码:toMap第三个参数可以指定当key 重复的时候值怎么取
final Map<Long,String> keyIdWithPathMap = attachmentInfoResponse.stream().collect(Collections.toMap(AttachmentInfoRespnse::getAssociateKeyId, item -> Optional.of(item.getxxx()).orElse),(v1,v2) -> v1);
https://blog.csdn.net/weixin_44422604/article/details/119888769
本文来自博客园,作者:chuangzhou,转载请注明原文链接:https://www.cnblogs.com/czzz/p/17975094

                
            
        
浙公网安备 33010602011771号