我是靠谱客的博主 光亮高山,这篇文章主要介绍RestTemplate 字段映射问题,现在分享给大家,希望可以做个参考。

RestTemplate 默认不开启驼峰式字段映射
需要通过jackson注解使用字段映射

restTemplate.postForEntity(uri, HttpEntity.EMPTY, responseType)

引入jackson pom

 <dependency>
     <groupId>com.fasterxml.jackson.core</groupId>
     <artifactId>jackson-annotations</artifactId>
 </dependency>

字段用上jackson注解 @JsonProperty

    @ApiModelProperty("accessToken")
    @JsonProperty("access_token")
    private String accessToken;

    @ApiModelProperty("tokenType")
    @JsonProperty("token_type")
    private String tokenType;

    @ApiModelProperty("refreshToken")
    @JsonProperty("refresh_token")
    private String refreshToken;

最后

以上就是光亮高山最近收集整理的关于RestTemplate 字段映射问题的全部内容,更多相关RestTemplate内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(132)

评论列表共有 0 条评论

立即
投稿
返回
顶部