import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.cj.supplier.model.SupplierProductImage;
public class test {
public static void main(String[] args){
List<SupplierProductImage> list = new ArrayList<> ();
SupplierProductImage sp = new SupplierProductImage ();
sp.setId (123L);
sp.setImageUrl ("123");
list.add (sp);
SupplierProductImage sp1 = new SupplierProductImage ();
sp1.setId (1234L);
sp1.setImageUrl ("1234");
list.add (sp1);
SupplierProductImage sp2 = new SupplierProductImage ();
sp2.setId (123L);
sp2.setImageUrl ("123dd");
list.add (sp2);
Map<Long, List<SupplierProductImage>> collect = list.stream().collect(Collectors.groupingBy(SupplierProductImage::getId));
System.out.println (JSON.toJSONString (collect));
}
}