Stream JSON output in Spring MVC

后端 未结 4 1754
粉色の甜心
粉色の甜心 2020-12-08 12:19

My application is built using Spring Boot(1.3.3.RELEASE) with Spring MVC, Spring data JPA Hibernate. MySql is the database and Jackson is the JSON serializer. On java 8.

4条回答
  •  借酒劲吻你
    2020-12-08 12:47

    Return Iterable from your controller

    Stream converts to an iterator by Iterable iterable = stream::iterator;

    @RequestMapping(value = "/candidates/all", method = RequestMethod.GET)
    public Iterable getAllCandidates(){
        ...
    
            return candidateDao.findAllByCustomQueryAndStream()::iterator;
    

提交回复
热议问题