1. 在.pom文件中添加openfeign的依赖

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

2.在application.properties中配置http的url地service_port=192.168.**.**:8899

3.新建一个service方法 不用写实现类

  3.1使用@FeignClient(url = "${service_port}",name = "Feign") //url为配置文件中定义的url Name可随便自定义
  3.2使用 @
GetMapping、@postMapping 或者 @RequestMapping去定义的请求的类型 和 具体接口地址
  3.3方法内可以传递需要的参数

        springboot中使用FeignClient调用http请求_json

 

 

 4.在控制层注入 service 调用即可

@Autowired
private AvoidService service ;
JSONObject user =  service.getUser(userId);