How to make @JsonSnakeCase the default for configuration in Dropwizard

后端 未结 3 1644
情书的邮戳
情书的邮戳 2021-02-14 02:26

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

相关标签:
3条回答
  • 2021-02-14 03:01

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

    environment.getObjectMapperFactory().setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
    
    0 讨论(0)
  • 2021-02-14 03:24

    Just add this following line in your run() method

    environment.getObjectMapper().setPropertyNamingStrategy(
            PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
    
    0 讨论(0)
  • 2021-02-14 03:25
    environment.jersey().register(new JacksonMessageBodyProvider(mapper));
    
    0 讨论(0)
提交回复
热议问题