package com.ningdatech.kqapi;

import com.ningdatech.basic.util.SpringUtils;
import com.ningdatech.kqapi.common.util.SpringContextHolder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author zpf
 */
@SpringBootApplication
@EnableAsync
@MapperScan(App.MAPPER_PACKAGES)
@EnableScheduling
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableTransactionManagement
@EnableAspectJAutoProxy(exposeProxy = true)
@ComponentScan(basePackages = {"com.ningdatech.kqapi", "com.ningdatech.kqapi.common"})
public class App {

    protected static final String MAPPER_PACKAGES = "com.ningdatech.kqapi.**.mapper";

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(App.class, args);
        // 设置applicationContext
        SpringUtils.setApplicationContext(context);
    }

    @Bean
    public SpringContextHolder springContextHolder() {
        return new SpringContextHolder();
    }

}
