原因: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
标签:toMap,stream,getAssociateKeyId,item,Collections,AttachmentInfoRespnse,bug From: https://www.cnblogs.com/czzz/p/17975094