のために利用可能なインスタンス私が使用していますリボン:localhostの
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>1.2.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
私のメインクラス:
@SpringBootApplication
//@Configuration
@ComponentScan(basePackages = "com.mypackage")
@EnableAutoConfiguration
@EnableEurekaClient
@EnableSwagger2
public class App
{
public static void main(String[] args)
{
SpringApplication.run(App.class, args);
}
@LoadBalanced
@Bean(name="template")
RestTemplate restTemplate() {
return new RestTemplate();
}
}
私のサービスの呼び出し:
@Autowired
private RestTemplate template;
ResponseEntity<String> avs = template.exchange("http://localhost:7075/xyz/json/authenticate",HttpMethod.POST ,request,String.class);
次の例外がスローされます
java.lang.IllegalStateException: でローカルホストのために利用可能なインスタンスorg.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute(RibbonLoadBalancerClient.java:90) org.springframework.cloud.client.loadbalancerで.RetryLoadBalancerInterceptor $ 1.doWithRetry(RetryLoadBalancerInterceptor.java:60) でorg.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor $ 1.doWithRetry(RetryLoadBalancerInterceptor.java:48) org.springframework.retry.support.RetryTemplate.doExecuteで(RetryTemplate.java:276) at org.springframework.retry.support.RetryTemplate。実行(RetryTemplate.java:157)
おかげで@spencergibb、もう一つ、私がネットフリックス(1.0.3)との通知があり、このような何か残りのテンプレートLoadBalancedを作成する必要がありますが、1.2.3ではそれが存在しません。 – atiwari54
いいえ、そこにあります。おそらくあなたの設定に何か問題があります。 – spencergibb