我使用 Spring Cloud Netflix 来构建我的微服务。
@FeignClient(name = "ms-cloud",configuration = MsCloudClientConfig.class)
public interface TestClient {
/**
* @return
*/
@RequestMapping(value = "/test", method = RequestMethod.GET)
String test();
}
当某些特殊用户时,我想将名称更改为 ms-cloud-pre。
任何人都可以提供一些建议吗?
最佳答案
根据documentation feign 支持 name
中的占位符和 url
字段。
@FeignClient(name = "${store.name}")
public interface StoreClient {
//..
}
所以你可以设置
store.name=storeProd
在运行时使用正常的 Spring Boot 配置机制。
关于spring - 如何在运行时更改@FeignClient 名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35168148/