EurekaServerInitializerConfiguration 注解加入Configuration Spring 便可以加载改类,该类
有一个线程启动方法:
@Override
public void start() {
new Thread(new Runnable() {
@Override
public void run() {
try {
//TODO: is this class even needed now?
eurekaServerBootstrap.contextInitialized(EurekaServerInitializerConfiguration.this.servletContext);
log.info(“Started Eureka Server”);
publish(new EurekaRegistryAvailableEvent(getEurekaServerConfig()));
EurekaServerInitializerConfiguration.this.running = true;
publish(new EurekaServerStartedEvent(getEurekaServerConfig()));
}
catch (Exception ex) {
// Help!
log.error(“Could not initialize Eureka servlet context”, ex);
}
}
}).start();
}
就会将Spring cloud服务启动起来。
EurekaServerBootstrap 与EurekaBootStrap 代码基本上一样。
EurekaBootStrap 实现了 ServletContextListener 随着线程服务启动,初始化环境变量和加载上下文对象到容器