package com.blueland.render;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.druid.stat.DruidStatManagerFacade;

import lombok.extern.slf4j.Slf4j;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Slf4j
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@ConfigurationPropertiesScan
@EnableConfigurationProperties
@EnableAsync
@ComponentScan(basePackages = { "com.blueland", "org.blueland" })
//@MapperScan(value = { "com.blueland" }, sqlSessionFactoryRef = "sqlSessionFactory")
public class WebApp {

//	@RestController
//	public class DruidStatController {
//		@GetMapping("/druid/stat")
//		public Object druidStat() {
//			// DruidStatManagerFacade#getDataSourceStatDataList 该方法可以获取所有数据源的监控数据，除此之外
//			// DruidStatManagerFacade 还提供了一些其他方法，你可以按需选择使用。
//			return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
//		}
//	}

	@Bean
	protected ServletContextListener listener() {
		return new ServletContextListener() {

			@Override
			public void contextInitialized(ServletContextEvent sce) {
				log.info("ServletContext initialized");
			}

			@Override
			public void contextDestroyed(ServletContextEvent sce) {
				log.info("ServletContext destroyed");
			}

		};
	}

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

}
