title: Spring : Cannot infer type arguments for ResponseEntity<>
body: <p>This is my first time using Spring with mongodb and I am creating a REST API to get items based on who created them  . With my code however I get the error <code>&quot;Cannot infer type arguments for ResponseEntity&lt;&gt;&quot;</code> and I do not understand why .</p>
  <p>My code :</p>
  <p>Memory.java (single item)</p>
  <pre><code>import org.springframework.data.annotation.Id;
  import org.springframework.data.mongodb.core.mapping.Document;
  
  @Document(collection=&quot;Memories&quot;)
  public class Memory {
  
      @Id
      private String id;
      private String message;
      private String title;
  
      public Memory() {
          
      }
      
      public Memory(String creator , String title  ) {
          this.title = title;
          this.creator=creator;
      }
      
  
      public String getId() {
          return id;
      }
          
      public void setCreator(String creator ) {
          this.creator=creator;
      }
  
   
  
      public String getCreator() {
          return creator;
      
      }
  
       public void  setTitle(String title){
        this.title=title;
       }
  
      public String getTitle(){
        return title;    
      }
  
      }
  </code></pre>
  <p>MemoryRepository.java (interface)</p>
  <pre><code>public interface MemoryRepository extends MongoRepository&lt;Memory,String&gt;{
  
    List&lt;Memory&gt; findByCreator(String creator);
  }
  </code></pre>
  <p>MemoryController.java (REST API )</p>
  <pre><code>@RestController
  @RequestMapping(&quot;/api&quot;)
  public class MemoryController {
  
      @Autowired
      MemoryRepository memoryRepo;
    
      //RETURNS MEMORIES BY CREATOR 
      @GetMapping(&quot;/memories/creator={creator}&quot;)
      public ResponseEntity&lt;Memory&gt; findByCreator(@PathVariable(&quot;creator&quot;) String creator){
          
          try {
              List&lt;Memory&gt;  memoriesFound = memoryRepo.findByCreator(creator);
              if(memoriesFound.isEmpty()) {
                  return new ResponseEntity&lt;&gt;(HttpStatus.NO_CONTENT);
              }else {
                  //THIS IS THE LINE WHERE I GET THE ABOVE ERROR 
                  return new ResponseEntity&lt;&gt;(memoriesFound,HttpStatus.OK);
              }
          }catch(Exception e) {
              return new ResponseEntity&lt;&gt;(HttpStatus.INTERNAL_SERVER_ERROR);
          }
      }
  
  }
  </code></pre>
  <p>I would appreciate your help with this . I looked at the docs of <code>ResponseEntity</code> but still no idea .</p>