pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
添加扫描
@EnableFeignClients("com.xxx.framework.xxx.client")
@SpringBootApplication
client代码
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "WeChat", url = "https://api.weixin.qq.com")
public interface WeChatClient {
@PostMapping("/sns/jscode2session")
String getSessionKeyOrOpenId(
@RequestParam("appid") String appid,
@RequestParam("secret") String secret,
@RequestParam("js_code") String jsCode,
@RequestParam("grant_type") String grantType
);
}