问题
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