我使用java 11,使用sts IDE,我从IDE编译并运行springboot应用程序,但是当我使用mvn从命令行编译它时
mvn clean verify
我犯了这个错误
cannot find symbol [ERROR] symbol: method toList()
代码片段是
......
......
return addressRepository.getAddressesBySystemUserId(systemUserId).stream().map(e -> {
AddressDto dto = null;
dto = AddressMapper.mapAddressToAddressDto(e);
return dto;
}).toList();
......
pom文件的片段
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
发布于 2022-02-22 10:53:20
您需要使用.collect()
从Java11中的流中收集列表。
return addressRepository.getAddressesBySystemUserId(systemUserId).stream().map(e -> {
AddressDto dto = null;
dto = AddressMapper.mapAddressToAddressDto(e);
return dto;
}).collect(Collectors.toList());
https://stackoverflow.com/questions/71219882
复制相似问题