1.在SpringBoot 启动类添加@EnableFeignClients注解
@EnableFeignClients
@SpringBootApplication(exclude = {FreeMarkerAutoConfiguration.class})
public class SaasQcApplication {
public static void main(String[] args) {
SpringApplication.run(SaasQcApplication.class, args);
}
}
2.@FeignClient定义feign客户端远程,映射远程地址
@FeignClient(name = "saasbasic", path = "saasbasic/", url = "http://192.168.110.77:8082/")
public interface OrderRemoteService {
@RequestMapping(value ="/system/bill/v1/genOrderNum/?areaId={areaId}&billType={billType}",method = RequestMethod.GET)
GlobalResponse genOrderNum(@RequestHeader("companyCode") String companyCode, @PathVariable("areaId")String areaId , @PathVariable("billType") Integer billType);
}
3.使用构造方法调用GlobalResponse 接收返回值
private final OrderProcessingPhaseService orderProcessing;
public OrderServiceImpl(OrderProcessingPhaseService orderProcessing) {
this.orderProcessing = orderProcessing;
}
GlobalResponse Response = orderRemoteService.genOrderNum(132456789,"778899" , 1006);