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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复