HuaHengServletInitializer.java 2.48 KB
package com.huaheng;

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.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;

/**
 * web容器中进行部署
 * 打war包
 * @author huaheng
 */
/*@MapperScan({"com.huaheng.pc.**.**.mapper","com.huaheng.api.**.**.mapper"})//打war包去掉注释
//添加SecurityAutoConfiguration.class,防止报java.lang.ArrayStoreException错
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })*/
public class HuaHengServletInitializer extends SpringBootServletInitializer
{
    @Bean // 此处相当于将undertow server注入到spring-context 中,这里相对于tomcat设置要多此动作
    public ServletWebServerFactory servletContainer() {
        UndertowServletWebServerFactory undertow = new UndertowServletWebServerFactory();
        return undertow;
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
    {
        return application.sources(HuaHengServletInitializer.class);
    }

    public static void main(String[] args)
    {
        //SpringApplication.run(HuaHengServletInitializer.class, args);
        System.out.println("***************  华恒WMS启动成功WAR  ***************\n" +
                " >>>     WMS_Servlet启动成功!     <<<  \n"+
                "     へ     /|▓\n"+
                "    /\7   ∠_/\n"+
                "    / │   / /\n"+
                "    │ Z _,< /  〈ヽ\n"+
                "    │  `   ヽ    / 〉\n"+
                "    Y     `/  / 〉\n"+
                "   ( ●  ヽ  ● /. 〈 /\n"+
                "  () (  | \  〈 \\n"+
                "    >_ ' _ . '│  //\n"+
                "   /へ    / )<| \\\n"+
                "   ヽ_)  (_/  │//\n"+
                "   7       | /\n"+
                "   >―r` ̄ ̄` `―_' \n"

        );
    }

}