zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package cn.autoform;
 
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
 
/**
 * 应用程序主入口
 * 
 * @author yangrx
 *
 */
@SpringBootApplication
@Configuration
@EnableTransactionManagement
@EnableApolloConfig({"auto-form", "msg"})
@ComponentScan(basePackages= {"cn.autoform", "com.iemsoft.framework.cloud"})
public class Application extends SpringBootServletInitializer{
 
    private static ApplicationContext applicationContext = null;
 
    public static void main(String[] args) throws Exception {
 
        SpringApplication boot = new SpringApplication(Application.class);
        boot.setBanner((environment, sourceClass, out)->{
            out.println("");
            out.println("                    _ooOoo_");
            out.println("                   o8888888o");
            out.println("                  88\" . \"88");
            out.println("                  (\"| -_- |\")");
            out.println("                   O\\ = /O");
            out.println("               ____/`---'\\____");
            out.println("             .   ' \\\\| |// `.");
            out.println("              / \\\\||| : |||// \\");
            out.println("            / _||||| -:- |||||- \\");
            out.println("              | | \\\\\\ - /// | |");
            out.println("            | \\_| ''\\---/'' | |");
            out.println("             \\ .-\\__ `-` ___/-. /");
            out.println("          ___`. .' /--.--\\ `. . __");
            out.println("       .\"\" '< `.___\\_<|>_/___.' >'\"\".");
            out.println("      | | : `- \\`.;`\\ _ /`;.`/ - ` : | |");
            out.println("        \\ \\ `-. \\_ __\\ /__ _/ .-` / /");
            out.println("======`-.____`-.___\\_____/___.-`____.-'======");
            out.println("                   `=---='");
            out.println(" ");
            out.println(".............................................");
            out.println("         佛祖保佑             永无BUG");
        });
        applicationContext = boot.run(args);
//        FormulaParam formulaParam = new FormulaParam();
//        formulaParam.setFormCommit(false);
//        formulaParam.setFormID("f26bf960ecbc3d80e5d0c8dc78043ed5");
//        String data = "{\"单行文本1\":\"111\",\"单行文本2\":\"222\",\"单行文本3\":\"333\",\"子表单\":[{\"数字1\":\"1\",\"数字2\":\"2\",\"数字3\":\"3\"},{\"数字1\":\"4\",\"数字2\":\"5\",\"数字3\":\"6\"}]}";
//        formulaParam.setData(JSONTool.toObj(data, Map.class));
//        System.err.println(data);
//        FormulaResult fr = applicationContext.getBean(FormulaServiceImpl.class).execute(formulaParam);
//        System.exit(0);
    }
 
    // 获取applicationContext
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }
 
    @Bean
    public ServletRegistrationBean statViewServlet() {
        ServletRegistrationBean reg = new ServletRegistrationBean();
        reg.setServlet(new StatViewServlet());
        reg.addUrlMappings("/druid/*");
        return reg;
    }
 
    @Bean
    public FilterRegistrationBean webStatFilter(){
        FilterRegistrationBean fr = new FilterRegistrationBean();
        fr.setFilter(new WebStatFilter());
        fr.addUrlPatterns("/*"); // /*"/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*".split(",")*/
        return fr;
    }
}