ユーレカには2つのサービスが登録されています。サービスCはサービスAを呼び出します。サービスCはクライアントです。私はfeignクライアントを手動で実装したい。しかし、私は例外をキャッチ:クライアントを手動で調整します。ロードバランサにクライアント用のサーバーがありません
com.netflix.client.ClientException:ロードバランサは、クライアントのために 利用可能なサーバーを持っていない:サービス・テスト・
Applicationクラス:
@EnableEurekaClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
装うインタフェース:
@Component
public interface FeignService {
@RequestLine("GET /")
public String getServiceA();
}
装うの設定:
@Configuration
@Import(FeignClientsConfiguration.class)
public class MyConfig {
}
コントローラー:
@RestController
public class Controller {
private FeignService feignService;
@Autowired
public void Controller() {
feignService = Feign.builder()
.client(RibbonClient.create())
.target(FeignService.class, "http://service-test-a");
}
@RequestMapping(value = "/build", method = RequestMethod.GET)
public String getServiceC() {
return feignService.getServiceA();
}
}
は私が間違って何をしているのですか?
を参照してください? –
私は公式の文書に従っています。https://github.com/OpenFeign/feign/tree/master/ribbon – Alexander
どの豆を使うべきか分かりません。私に教えてください。 – Alexander