Java 这个错误在我的流图中是什么意思?

Java 这个错误在我的流图中是什么意思?,java,Java,错误: lambda表达式中的代码块不返回任何内容,但是.map()方法需要一个返回内容的函数/lambda 您应该将代码编写为 return ratings.stream() .map(rating -> { Movie movie=restTemplate.getForObject("http://localhost:8081/movies/"+rating.getMovieId(), Movi

错误:


lambda表达式中的代码块不返回任何内容,但是
.map()
方法需要一个返回内容的函数/lambda

您应该将代码编写为

return ratings.stream()
                .map(rating -> {
                    Movie movie=restTemplate.getForObject("http://localhost:8081/movies/"+rating.getMovieId(), Movie.class);
                    new CatalogItem(movie.getName(),movie.getDescription(),rating.getRating());
        })
        .collect(Collectors.toList());
return ratings.stream()
                .map(rating -> {
                    Movie movie=restTemplate.getForObject("http://localhost:8081/movies/"+rating.getMovieId(), Movie.class);
                    new CatalogItem(movie.getName(),movie.getDescription(),rating.getRating());
        })
        .collect(Collectors.toList());
return ratings.stream()
           .map(rating -> {
               Movie movie=restTemplate.getForObject("http://localhost:8081/movies/"+rating.getMovieId(), Movie.class);
               return new CatalogItem(movie.getName(),movie.getDescription(),rating.getRating());
           })
           .collect(Collectors.toList());