package com.rehome.jpahefengweather;

import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;


@EnableJpaAuditing
@EnableScheduling
@SpringBootApplication
public class JpahefengweatherApplication extends SpringBootServletInitializer implements ApplicationContextAware {

    public static ApplicationContext context;

    public static void main(String[] args) {
        SpringApplication.run(JpahefengweatherApplication.class, args);
    }

    /**
     * @date 2022-03-14 15:20
     * @description: 容器配置，springboot打war包布署必须添加这个配置 为了打包springboot项目
     * @Param: SpringApplicationBuilder
     */
    @Override
    protected SpringApplicationBuilder configure(
            SpringApplicationBuilder builder) {
        return builder.sources(JpahefengweatherApplication.class);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }
}