首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Cloud with Liberty

Spring Cloud with Liberty
EN

Stack Overflow用户
提问于 2016-08-11 22:18:21
回答 2查看 295关注 0票数 0

我目前在Websphere Liberty中运行Spring Boot应用程序,并使用Consul for Service Discovery。为了向Consul注册服务,我创建了一个连接到Application Lifecycle事件并执行注册/deregistration的特权特性。这很好用,但这样做是将我自己与Liberty结合在一起。Spring-Cloud-Consul看起来可以解决这个问题,但我不能让它向Liberty注册服务(它确实连接到Consul) -只能使用嵌入式Tomcat Server。在查看了Spring-Cloud-Consul代码之后,问题是没有触发EmbeddedServletContainerInitializedEvent,所以没有设置端口。

我的问题是,Spring Cloud Consul只适用于嵌入式servlet容器吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-08-11 22:47:21

这是一个已知的问题。请随时提交公关。https://github.com/spring-cloud/spring-cloud-consul/issues/173

票数 0
EN

Stack Overflow用户

发布于 2016-08-25 04:15:38

我的解决方案是将spring-cloud-consul的ConsulLifecycle类放在本地,并添加一个ApplicationReadyEvent,如下所示:

代码语言:javascript
复制
@Autowired(required = false)
private ServerProperties serverProperties;

@EventListener
public void onApplicationReady(ApplicationReadyEvent event) {
    this.setConfiguredPort(serverProperties.getPort());
    log.info("Application ready on port " + serverProperties.getPort());
    this.start();
}

现在,我的服务按照预期进行了注册和注销。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38898950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档