title: Making spring-data-mongodb multi-tenant
body: <p>In a <a href="https://stackoverflow.com/questions/12078669/spring-data-mongodb-connect-to-multiple-databases-in-one-mongo-instance">post</a> last august <a href="https://stackoverflow.com/users/229178/sbzoom">sbzoom</a> proposed a solution to make spring-data-mongoDB multi-tenant:</p>
  
  <p>"You have to make your own RepositoryFactoryBean. Here is the example from the <a href="http://static.springsource.org/spring-data/data-mongodb/docs/1.1.0.RC1/reference/html/#repositories.custom-behaviour-for-all-repositories" rel="noreferrer">Spring Data MongoDB Reference Docs</a>. You would still have to implement your own MongoTemplate and delay or remove the ensureIndexes() call. But you would have to rewrite a few classes to make sure your MongoTemplate is called instead of Spring's."</p>
  
  <p>Did anybody implement this or something equivalent?</p>