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; } }