openfeign 整合 springboot 实现 带有token的调用

在使用openfeign的时候会有401等会画过期等问题 配置一下openfegin config即可

1.springboot添加pom文件

		<!-- openfeign  -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-openfeign</artifactId>
		</dependency>

2.创建接口

/**
 * @Date 2020/7/1 09:37
 * @Created by gaoyuanfeng
 */
@FeignClient(value = "isim-device-service")
public interface OpenFeignDeviceService {
   

    @PostMapping("device/api/tenants/TemporaryPlan")
    ResponseEntity<?> insTemporaryPlan(@RequestBody TemporaryPlanDTO dto);

}

isim-device-service 为想调用的服务
url写全


3.添加FeignConfig


/*
 * @(#)FeignConfig.java	2020618日下午5:16:

你可能感兴趣的:(java,spring)