springboot调用外部接口FeignClient

依赖包:
 
  
<dependency>
    <groupId>org.springframework.cloudgroupId>
    <artifactId>spring-cloud-starter-feignartifactId>
    <version>1.2.2.RELEASEversion>
dependency>
除了以上,还得在Application配置可用包路径
@EnableFeignClients("com.gy.api")

如调用百度的一个api
 
  
@FeignClient(url = "${baidumap.url}",name="bmurl")
public interface BaiduApi {
@RequestMapping(value="/routematrix/v2/driving",method= RequestMethod.GET)
public String getdis(@RequestParam("ak") String ak,
                     @RequestParam("output") String json,
                     @RequestParam("origins") String origins,
                     @RequestParam("destinations") String destinations
);
}
 
  

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