package com.usoftchina.bi.server;

import com.usoftchina.bi.core.utils.ContextUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.context.WebApplicationContext;

/**
 * @Author chenwei
 * @Date 2019-04-08
 */
public class SpringbootStartApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder){
        return applicationBuilder.sources(Application.class);
    }

    @Override
    protected WebApplicationContext run(SpringApplication application) {
        ConfigurableApplicationContext app =  application.run();
        ContextUtil.setApplicationContext(app);
        return (WebApplicationContext) app;
    }

}
