当在带有嵌入式 tomcat 的 Spring Boot 中运行代码时,Spring Cloud Consul 按预期工作。
当我们在独立的tomcat上部署代码时,它不起作用。似乎有一个ConsulAutoServiceRegistrationListener
,它在WebServerInitializedEvent
上启动consul服务注册。仅当我们在嵌入 Tomcat 的 Spring Boot 中运行代码时才会触发此事件。
https://github.com/spring-cloud/spring-cloud-consul/issues/302 提供了几种解决方法但它们都不再适用于最新的 Greenwich.RC2
版本。
我们可以通过哪些其他方式在独立的 tomcat 上启动服务注册?
如果您需要更多详细信息,请告诉我。
最佳答案
我认为您可以设置 spring.cloud.consul.discovery.port=${server.port}
并且不需要 setPort()
方法。
关于java - 为什么 Spring Cloud Consul 不能与独立的 Tomcat 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54148550/