If you need multiple service instances on the same host, you explicitly specify their instanceId when they start as follows:
mvn spring-boot:run -Dserver.port=8081 -Deureka.instance.metadataMap.instanceId=instance1 mvn spring-boot:run -Dserver.port=8082 -Deureka.instance.metadataMap.instanceId=instance2 ...
Or
java -jar target/app.jar -Dserver.port=8081 -Deureka.instance.metadataMap.instanceId=instance1 ...
You can also do this dynamically by specifying this in the application properties file:
eureka.instance.instanceId: applicationname:${spring.application.instance_id:${random.value}}
And I'm not sure that this is connected, but the refusal to register with the eureka took a very long time when I closed the instances (they can never cancel the registration), so I had to switch the self-preservation mode:
eureka.server.enable-self-preservation to false
Victor petit
source share