title: Creating a generic mongo repository in spring boot
body: <p>I want to create a generic mongo repository and just pass the document and use it, instead of creating multiple repositories for each document.</p>
  <p>So far this is what I thought about:</p>
  <pre><code>@NoRepositoryBean
  public interface GenericRepository&lt;T, String&gt; extends MongoRepository&lt;T,String&gt; {
   T findById(ObjectId id);
  }
  
  
  @RestController
  @RequestMapping(&quot;/endpoint&quot;)
  public class Controller {
  
      @Autowired
      public GenericRepository&lt;DocumentClass, String&gt; repository;
  
      @GetMapping(&quot;/&quot;)
      public List&lt;DocumentClass&gt; all(){
          return repository.findAll();
      }
  
  }
  </code></pre>
  <p>I'm not sure this is the correct way of doing so because I'm getting a lot of errors.</p>