springcloud 2.1.0RELEASE 通过Tomcat启动,无法注册consul服务问题
通过Tomcat启动不会注册consul服务问题:spring cloud 2.1 consul 注册是通过监听WebServerInitializedEvent事件,通过tomcat容器启动服务时监听不到WebServerInitializedEvent事件,Consul无法注册服务,可以加入下面代码: @Componentpublic class CustomizedEventL...
·
通过Tomcat启动不会注册consul服务问题:
spring cloud 2.1 consul 注册是通过监听WebServerInitializedEvent事件,通过tomcat容器启动服务时监听不到WebServerInitializedEvent事件,Consul无法注册服务,可以加入下面代码:
@Component
public class CustomizedEventLinsiners implements ApplicationListener<ContextRefreshedEvent>{
@Autowired
ConsulAutoServiceRegistration consulAutoServiceRegistration;
@Autowired
ConsulDiscoveryProperties properties;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
consulAutoServiceRegistration.start();
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)