Home | 简体中文 | 繁体中文 | 杂文 | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | Github | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | 打赏(Donations) | About
知乎专栏多维度架构

10.4. Openfeign

10.4.1. Openfeign 扫描包配置

		
@EnableFeignClients(basePackages = {"cn.netkiller.openfeign"})		
		
		

10.4.2. 用户认证

		
@Configuration
@EnableFeignClients
public class FeignConfiguration {
    @Bean
    public Contract feignContract() {
        return new feign.Contract.Default();
    }

    @Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
        return new BasicAuthRequestInterceptor("user", "password");
    }
}		
		
		

10.4.3. 配置连接方式

启用 okhttp

		
feign.okhttp.enabled=true
		
		

httpclient

		
feign.httpclient.enabled=true		
		
		

10.4.4. 

		
@FeignClient(name="myServiceName", url="localhost:8888")
public interface OpenfeignService {
	@RequestMapping("/")
	public String getName();
}