How to set Mongodb Field Naming Strategy in Spring boot

时光总嘲笑我的痴心妄想 提交于 2019-12-10 10:43:39

问题


I am using spring boot 1.3.1.Release with Spring Data Mongodb and want to setup field naming strategy for fields. Below is my application.properties file:

spring.data.mongodb.uri=mongodb://localhost/test
spring.data.mongodb.field-naming-strategy=org.springframework.data.mongodb.core.mapping.SnakeCaseFieldNamingStrategy
spring.data.mongodb.repositories.enabled=true
spring.data.mongodb.database=test

Everything is working fine except the field naming strategy. Any help will be highly appreciated.


回答1:


SpringBoot 1.3 has spring-data-mongodb version 1.8 and in this version of jar class with name SnakeCaseFieldNamingStrategy is not present.

Checked with the api docs here.. http://docs.spring.io/spring-data/mongodb/docs/1.8.0.RELEASE/api/

I guess u need to degrade the version of spring-data-mongodb to 1.5 or so. Probably this is the reason your Field naming strategy is not working.



来源:https://stackoverflow.com/questions/34523125/how-to-set-mongodb-field-naming-strategy-in-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!