에 사용할 수있는 인스턴스 내가 사용하고리본 : 로컬 호스트
<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);
다음 예외가 throw됩니다.
java.lang.IllegalStateException : 로컬 호스트 에 사용할 수있는 인스턴스 org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient.execute (RibbonLoadBalancerClient.java:90)에서 org.springframework.cloud.client.loadbalancer에서 org.springframework.retry.support.RetryTemplate.doExecute에서 org.springframework.cloud.client.loadbalancer.RetryLoadBalancerInterceptor $ 1.doWithRetry (RetryLoadBalancerInterceptor.java:48) 에서 .RetryLoadBalancerInterceptor $ 1.doWithRetry (RetryLoadBalancerInterceptor.java:60) (RetryTemplate.java:276) at org.springframework.retry.support.RetryTemplate. 실행 (RetryTemplate.java:157)
덕분에 @spencergibb, 한 가지 더 내가 (1.0.3) 넷플 릭스와 공지 사항을 나머지 템플릿은 LoadBalanced를 만들 필요가 있지만 1.2.3에서는 그렇지 않습니다. – atiwari54
아니, 거기 있네. 아마도 구성에 문제가있을 수 있습니다. – spencergibb