@FeignClient
に使用するサーバーのリストを構成できません。私はSpring Cloud Netflixを使用していますが、この特定のサービス(foo-service
)はユーレカに登録しません。このため、YMLファイルにfoo-service
のサーバのリストを設定する必要があります。@FeignClientをサーバーのリストで構成できません
ただし、listOfServers
は決して読み込まれないため、Feign/Ribbonは使用する単一のサーバーを持たないため、操作は失敗します。
私はここで間違っていますか?
マイ装うクライアント:bootstrap.ymlで
@FeignClient(name="foo-service")
public interface FooFeignClient {
@RequestMapping(value = "/perform-check", method = POST)
ResponseEntity<FooResponse> performCheck(FooRequest fooRequest);
}
:
装うクライアントは春のブートアプリケーションで設定されているどのようfoo-service:
ribbon:
eureka:
enabled: false
listOfServers: foobox1,foobox2,foobox3
:
@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableHazelcastClient
@EnableFeignClients
@RibbonClients({
@RibbonClient(name = "foo-service", configuration = MyApp.FooServiceRibbonConfig.class)
})
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
....
@Configuration
static class FooServiceRibbonConfig {
@Bean
@ConditionalOnMissingBean
public IClientConfig ribbonClientConfig() {
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.loadProperties("foo-service");
return config;
}
@Bean
ServerList<Server> ribbonServerList(IClientConfig config) {
ConfigurationBasedServerList serverList = new ConfigurationBasedServerList();
serverList.initWithNiwsConfig(config);
return serverList;
}
}
}
'listOfServers'は大文字と小文字を区別し、' ListOfServers'である必要があります。 – spencergibb
@spencergibb 'ListOfServers'も機能しませんでした。私はここのアドバイスに従うことを試みたhttps://github.com/spring-cloud/spring-cloud-netflix/issues/325 – vegemite4me
問題を再現するサンプルプロジェクトを提供する必要があります。 – spencergibb