Vi um tópico sobre o mesmo problema:
https://cursos.alura.com.br/forum/topico-problema-no-service-discovery-com-eureka-url-do-fornecedor-com-resttemplate-97286
Porém meus servers não estão com aspas nos nomes...
Seguem os codigos:
package br.com.alura.microservicos.loja;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
public class LojaApplication {
@Bean
@LoadBalanced
public RestTemplate getRestTamplate() {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(LojaApplication.class, args);
}
}
package br.com.alura.microservicos.loja.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import br.com.alura.microservicos.loja.dto.CompraDTO;
import br.com.alura.microservicos.loja.dto.InfoFornecedorDTO;
@Service
public class CompraService {
@Autowired
private RestTemplate client;
public void realizaCompra(CompraDTO compra) {
ResponseEntity<InfoFornecedorDTO> exchange = client.exchange(
"http://fornecedor/info/"+compra.getEndereco().getEstado(), HttpMethod.GET, null,
InfoFornecedorDTO.class);
System.out.println(exchange.getBody().getEndereco());
}
}
server.port=8081
spring.jpa.database=MYSQL
spring.datasource.url=jdbc:mysql://localhost/fornecedor?createDatabaseIfNotExist=true&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=1234
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
spring.application.name=fornecedor
eureka.client.register-with-eureka= true
eureka.client.fetch-registry=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
spring.application.name=loja
eureka.client.register-with-eureka= true
eureka.client.fetch-registry=true
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
Abaixo vou colocar os logs.