@EnableFeignClients(basePackages = {"cn.netkiller.openfeign"})
@Configuration
@EnableFeignClients
public class FeignConfiguration {
@Bean
public Contract feignContract() {
return new feign.Contract.Default();
}
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor("user", "password");
}
}
啟用 okhttp
feign.okhttp.enabled=true
httpclient
feign.httpclient.enabled=true
@FeignClient(name="myServiceName", url="localhost:8888")
public interface OpenfeignService {
@RequestMapping("/")
public String getName();
}