Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

não consigo usar a a url fornecedor, só funciona com localHost

nã "Internal Server Error", "trace": "org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://fornecedor/info/GO\": eureka; nested exception is java.net.UnknownHostException: eureka\r\n\tat org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)\r\n\tat org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)\r\n\ta

@Service public class CompraService { @Autowired private RestTemplate restTemplate; public void realizarCompra(CompraDto compraDto) {

    ResponseEntity<infoFornecedorDto> exchange = restTemplate.exchange("http://fornecedor/info/" + compraDto.getEndereco().getEstado(),
            HttpMethod.GET, null, infoFornecedorDto.class);

    System.out.println(exchange.getBody().getEndereco());
}

}

3 respostas

properties loja

spring.application.name=loja

eureka.client.register-with-eureka= true eureka.client.prefer-same-zone-eureka=true eureka.instance.hostname=eureka

classe main da loja

@SpringBootApplication @EnableDiscoveryClient public class SpringCloudApplication {

@Bean
@LoadBalanced //faz comm que ressolva as informações do ip e porta
public RestTemplate getRestTemplete()  {
    return new RestTemplate();
}

public static void main(String[] args) {
    SpringApplication.run(SpringCloudApplication.class, args);
}

}

solução!

properties fornecedor

server.port=8081

#banco de dados spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/fornecedor spring.datasource.username=root spring.datasource.password=123 spring.datasource.testWhileIdle=true spring.datasource.validationQuery=SELECT 1 spring.datasource.driver-class-name=org.mariadb.jdbc.Driver spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImproveNamingStrategy

server eureka

spring.application.name=fornecedor eureka.client.register-with-eureka= true eureka.client.prefer-same-zone-eureka=true eureka.instance.hostname=eureka