客户端配置
spring:
application:
name: ABCProductService
profiles: CLOUD
server:
port: 9000
eureka:
client:
registerWithEureka: true
fetchRegistry: true
region: default
serviceUrl:
defaultZone: http://localhost:3000/eureka
instance:
preferIpAddress: false
RestTemplate配置:
@Bean
@LoadBalanced
public RestTemplate getTemplate() {
return new RestTemplate();
}
但是在解析网址时会显示异常
@Autowired
private RestTemplate template;
@GetMapping("/ABC/{productid}")
public String getProductPrice(@PathVariable String productid) {
return template.getForObject("http://ABCPaymentService/v1/"+productid+"/getPrice", String.class);
}
正在获取:java.net.UnknownHostException: ABCPaymentService
有人可以帮我吗