Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 带注释的假客户机_Spring_Annotations_Autowired - Fatal编程技术网

Spring 带注释的假客户机

Spring 带注释的假客户机,spring,annotations,autowired,Spring,Annotations,Autowired,我正在尝试使用带注释的假客户端@FeignClient。我想手动调用faignclient方法。当我使用Feign.Builder手动构建feignclient时,它工作正常。但是我在使用@FeignClient注释时有点迷失了方向 谢谢, 当您想要手动创建fiegn客户端时,将使用KhushFeign.Builder 例如: @Import(FeignClientsConfiguration.class) class FooController { private FooClient

我正在尝试使用带注释的假客户端
@FeignClient
。我想手动调用
faignclient
方法。当我使用
Feign.Builder
手动构建
feignclient
时,它工作正常。但是我在使用
@FeignClient
注释时有点迷失了方向

谢谢,
当您想要手动创建fiegn客户端时,将使用Khush

Feign.Builder

例如:

@Import(FeignClientsConfiguration.class)
class FooController {

    private FooClient fooClient;

    private FooClient adminClient;

    @Autowired
    public FooController(
            ResponseEntityDecoder decoder, SpringEncoder encoder, Client client) {
        this.fooClient = Feign.builder().client(client)
                .encoder(encoder)
                .decoder(decoder)
                .requestInterceptor(new BasicAuthRequestInterceptor("user", "user"))
                .target(FooClient.class, "http://PROD-SVC");
        this.adminClient = Feign.builder().client(client)
                .encoder(encoder)
                .decoder(decoder)
                .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
                .target(FooClient.class, "http://PROD-SVC");
    }
}
@FeignClient-当您仅在接口中定义方法声明,并且spring负责在服务器启动时为您创建一个生成器时,就会使用它

@FeignClient("stores")
public interface StoreClient {
    @RequestMapping(method = RequestMethod.GET, value = "/stores")
    List<Store> getStores();

    @RequestMapping(method = RequestMethod.POST, value = "/stores/{storeId}", consumes = "application/json")
    Store update(@PathVariable("storeId") Long storeId, Store store);
}
@FeignClient(“商店”)
公共接口存储客户端{
@RequestMapping(method=RequestMethod.GET,value=“/stores”)
列出getStores();
@RequestMapping(method=RequestMethod.POST,value=“/stores/{storeId}”,consumes=“application/json”)
存储更新(@PathVariable(“storeId”)Long-storeId,Store-Store);
}

在此问题中添加“外国”和“微服务”标签。