feign

启用

SpringBoot入口启动类添加注解@EnableFeignClients

设置动态header

1
2
3
4
5
6
7
8

//定义方法时设置
@GetMapping(value = "/api/business/contract/info",headers = {"X-ApiKey=${contract.token}"})
String getContractBySn(@RequestParam("ContractSn") String contractSn);

// 调用时设置
@PostMapping(value = “/getStuDetail”)
public ReturnInfo getStudentDetail(@RequestBody Map map,@RequestHeader(name = “token”) String token);

处理LocalDateTime

添加依赖

1
2
3
4
5
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.9</version>
</dependency>

实体属性上

1
2
3
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime createTime;