我的问题是java.lang.IllegalStateException: Duplicate key每次尝试映射String时都会遇到List. 有没有办法编辑此实现以某种方式处理重复键?或者我应该用另一种方式来做吗?
Map<String, List<Fee>> feeAccountMap = ContractList
.stream()
.filter(o -> !o.getStatus().equals(ContractStatus.CLOSED))
.collect(Collectors.toMap(o -> o.getFeeAccount(), o -> {
List<Fee> monthlyFees;
try {
monthlyFees = contractFeeService.getContractMonthlyFees(o);
} catch (Exception e) {
throw new RuntimeException(e);
}
return monthlyFees;
}
));
精慕HU
相关分类