如何在Spring启动中设置Mongodb字段命名策略 [英] How to set Mongodb Field Naming Strategy in Spring boot
问题描述
我正在使用spring boot 1.3.1。请使用Spring Data Mongodb,并希望为字段设置字段命名策略。下面是我的application.properties文件:
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.
推荐答案
SpringBoot 1.3有spring-data-mongodb 1.8版本,在这个版本的jar类中有名称 SnakeCaseFieldNamingStrategy 不存在。
SpringBoot 1.3 has spring-data-mongodb version 1.8 and in this version of jar class with name SnakeCaseFieldNamingStrategy is not present.
使用此处的api文档进行检查..
http://docs.spring.io/spring-data/mongodb/docs/1.8.0。 RELEASE / api /
Checked with the api docs here.. http://docs.spring.io/spring-data/mongodb/docs/1.8.0.RELEASE/api/
我想你需要将spring-data-mongodb的版本降级为1.5左右。可能这就是你的Field命名策略不起作用的原因。
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.
这篇关于如何在Spring启动中设置Mongodb字段命名策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!