RestTemplate引入方式为:
@Autowired
public RestTemplate restTemplate;
时报错,错误信息如下
错误:'org.springframework.web.client.RestTemplate' that could not be found.
改为:
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
String providerMsg = restTemplate().getForEntity("http://localhost:8009/ecif-business/PrpObject/test",String.class).getBody();
System.out.println("Hello,Customer! msg from provider : <br/><br/> " + providerMsg);;
后即正确
此种方式为Spring Boot<=1.3时使用的,在>=1.4版本后,可以通过RestTemplateBuilder来使用。
@Autowired
public RestTemplate restTemplate;
时报错,错误信息如下
错误:'org.springframework.web.client.RestTemplate' that could not be found.
改为:
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
String providerMsg = restTemplate().getForEntity("http://localhost:8009/ecif-business/PrpObject/test",String.class).getBody();
System.out.println("Hello,Customer! msg from provider : <br/><br/> " + providerMsg);;
后即正确
此种方式为Spring Boot<=1.3时使用的,在>=1.4版本后,可以通过RestTemplateBuilder来使用。