How to make @JsonSnakeCase the default for configuration in Dropwizard

僤鯓⒐⒋嵵緔 提交于 2019-12-04 17:49:48

问题


How will I configure jackson to use snake case in dropwizard instead of putting @JsonSnakeCase in every class ?


回答1:


And finally am able to find the answer.. Just add below cofiguration.

environment.getObjectMapperFactory().setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)



回答2:


Just add this following line in your run() method

environment.getObjectMapper().setPropertyNamingStrategy(
        PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);



回答3:


environment.jersey().register(new JacksonMessageBodyProvider(mapper));


来源:https://stackoverflow.com/questions/20547935/how-to-make-jsonsnakecase-the-default-for-configuration-in-dropwizard

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