spring-dataspring-boot

Spring Boot & MongoDB how to remove the '_class' column?


When inserting data into MongoDB Spring Data is adding a custom "_class" column, is there a way to eliminate the "class" column when using Spring Boot & MongoDB?

Or do i need to create a custom type mapper?

Any hints or advice?


Solution

  • I think you need to create a @Bean of type MongoTemplate and set the type converter explicitly. Details (non-Boot but just extract the template config): http://www.mkyong.com/mongodb/spring-data-mongodb-remove-_class-column/