spring-guides/tut-rest

Cannot find stream method

FabioFriz opened this issue · 4 comments

Hi,
I had some problems with stream method, so I had to substitute each call like repository.findAll().stream() with StreamSupport.stream(repository.findAll().spliterator(), false).

The first thing that comes to mind is, are you using Java 8+, or Java 7. Because the stream() method being added to java.util.Collection (parent interface of java.util.List) isn't until JDK 8.

It's the same thing I thought of, but I'm using Java 11.0.2

As of 63d3937, all the repositories extend JpaRepository from Spring Data JPA, not CrudRepository from Spring Data Commons.

The findAll() method returns a List, so .stream() is available.