Spring cloud consul works as expected when run code inside a spring boot with embedded tomcat.
It doesn't work when we deploy code on the standalone tomcat.It appears there is a ConsulAutoServiceRegistrationListener
which starts consul service registration on WebServerInitializedEvent
. This event is only triggered when we run code inside a spring boot with embedded tomcat.
There are couple of workarounds provided at https://github.com/spring-cloud/spring-cloud-consul/issues/302 but none of them work any longer with latest Greenwich.RC2
release.
What are the other ways we can kick off the service registration on the standalone tomcat ?
Let me know if you need more details.
I think you can set spring.cloud.consul.discovery.port=${server.port}
and don't need the setPort()
method.