package com.ruoyi;

//import com.googlecode.aviator.AviatorEvaluator;
//import com.ruoyi.ames.bean.UserDefinedFunction;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 启动程序
 *
 * @author Leo
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableScheduling
@EnableTransactionManagement
@MapperScan("com.ruoyi.**.mapper")
public class RuoYiApplication
{
    public static void main(String[] args)
    {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  系统启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "\n" +
                "$$\\   $$\\ $$$$$$$\\   $$$$$$\\  $$$$$$$\\  $$$$$$$\\\n" +
                "$$ |  $$ |$$  __$$\\ $$ ___$$\\ $$  __$$\\ $$  __$$\\\n" +
                "$$ |  $$ |$$ |  $$ |\\_/   $$ |$$ |  $$ |$$ |  $$ |\n" +
                "$$$$$$$$ |$$$$$$$\\ |  $$$$$ / $$ |  $$ |$$$$$$$  |\n" +
                "$$  __$$ |$$  __$$\\   \\___$$\\ $$ |  $$ |$$  ____/\n" +
                "$$ |  $$ |$$ |  $$ |$$\\   $$ |$$ |  $$ |$$ |\n" +
                "$$ |  $$ |$$$$$$$  |\\$$$$$$  |$$$$$$$  |$$ |\n" +
                "\\__|  \\__|\\_______/  \\______/ \\_______/ \\__|\n" +
                "\n"
        );
        //AviatorEvaluator.addFunction(new UserDefinedFunction());
    }

    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer(){
        return factory -> {
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/");
            factory.addErrorPages(error404Page);
        };
    }
}
