title: How to return a set of objects with Spring Boot?
body: <p>I did <a href="https://spring.io/guides/gs/rest-service/" rel="noreferrer">a lesson</a> about <code>Spring Boot</code> and it works perfectly. But what if I want to return a set of objects ? I tried doing <a href="https://stackoverflow.com/questions/35266289/how-to-get-list-of-objects-via-requestbody-in-spring-boot-api">this</a> but it doesn't work. How can I do it correctly ?</p>
  
  <p><strong><em>With one object (it works):</em></strong></p>
  
  <pre><code>@RequestMapping("/greeting")
  public Greeting greeting(@RequestParam(value="name", defaultValue = "World") String name) {
      return new Greeting(counter.incrementAndGet(),
              String.format(template, name));
  }
  </code></pre>
  
  <p><strong><em>With many objects (it doesn't work):</em></strong></p>
  
  <pre><code>@RequestMapping(value = "/greeting", method = RequestMethod.GET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
  public @ResponseBody List&lt;Greeting&gt; greeting() {
      Greeting greeting1 = new Greeting(1, "One");
      Greeting greeting2 = new Greeting(2, "Two");
      List&lt;Greeting&gt; list = new ArrayList&lt;&gt;();
      list.add(greeting1);
      list.add(greeting2);
      return list;
  }
  </code></pre>