项目中使用的mysql版本 8 Spring Security jdk8新特性 如何使用 Java Stream API ,一行代码将 List 转换为 Map 类型 List<User> userList = getUserList(); Map<Integer, User> idAndUserMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));