I have 2 dockerized
spring boot microservices:
Address service is called by person service using webclient
as follows:
public Optional<Address> findByAddressNo(int addressNo) {
return Optional.ofNullable(
WebClient.create()
.get()
.uri("http://address-api:8080/address/" + addressNo)
.retrieve()
.bodyToMono(Address.class)
.block());
}
The docker compose
file for the address service contains the following:
services:
address-api:
build: .
restart: always
ports:
- "8083:8080"
depends_on:
sale:
condition: service_healthy
hostname: address-api
and app.props is:
spring.data.mongodb.host=address
spring.data.mongodb.port=27017
spring.data.mongodb.database=address
I can hit my person service endpoint ok, but when it makes the call to the address service I get the following:
{
"message": "Internal Server Error: Failed to resolve 'address-api' [A(1)]"
}
I am starting both micro services separately via docker-compose
, i.e. running docker compose up in each project.
What is the issue here, I am assuming I have configured something incorrectly.