zoukankan      html  css  js  c++  java
  • SpringBoot之使用外部的启动类

    公司内部统一包装了启动类,TradeBootStrap

    @EnableLionConfig
    @SpringBootApplication(
        excludeName = {"${exclude.auto-configuration.name}"},
        scanBasePackages = {"${scan.basePkg.path}", "com.ymm.trade", "com.ymm.architecture.*", "com.ymm.unify.authorization.*", "com.ymm.framework.healthcheck.client.*"}
    )
    @ServletComponentScan
    @PropertySource(
        value = {"classpath:default.properties", "classpath:application.properties"},
        factory = TradePropertySourceFactory.class
    )
    @ImportResource(
        locations = {"${custom.resource.import:classpath*:spring/spring-*.xml}", "classpath*:authorization/pigeon-service.xml"},
        reader = TradeImportResourceReader.class
    )
    public class TradeBootStrap {
        private static final BusinessLogger LOGGER = TLoggerFactory.getBusinessLogger(TradeBootStrap.class);
    
        public TradeBootStrap() {
        }
    
        public static void main(String[] args) {
            long startTime = System.currentTimeMillis();
            boolean var10 = false;
    
            long endTime;
            label50: {
                try {
                    var10 = true;
                    LOGGER.warn(BusinessLogSchema.of().message("TradeBootStrap start at = {}", new Object[]{DateFormats.DATE_TIME.format(startTime)}));
                    checkSwimlane();
                    SpringApplication springApplication = new SpringApplication(new Class[]{TradeBootStrap.class});
                    springApplication.addListeners(new ApplicationListener[]{new ApplicationPidFileWriter()});
                    springApplication.run(args);
                    var10 = false;
                    break label50;
                } catch (Throwable var11) {
                    LOGGER.error(BusinessLogSchema.of().errorCode(ErrorCode.code("INNER_BOOTSTRAP_001", new Object[0])).exception(var11));
                    var10 = false;
                } finally {
                    if (var10) {
                        long endTime = System.currentTimeMillis();
                        BusinessLogSchema.of().message("TradeBootStrap end at = {}, Cost = {}", new Object[]{DateFormats.DATE_TIME.format(startTime), endTime - startTime + "ms"});
                    }
                }
    
                endTime = System.currentTimeMillis();
                BusinessLogSchema.of().message("TradeBootStrap end at = {}, Cost = {}", new Object[]{DateFormats.DATE_TIME.format(startTime), endTime - startTime + "ms"});
                return;
            }
    
            endTime = System.currentTimeMillis();
            BusinessLogSchema.of().message("TradeBootStrap end at = {}, Cost = {}", new Object[]{DateFormats.DATE_TIME.format(startTime), endTime - startTime + "ms"});
        }

      之前一直没注意到这个注解 @SpringBootApplication

      其实他包含了 @EnableAutoConfiguration

    @Target(ElementType.TYPE)
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @Inherited
    @SpringBootConfiguration
    @EnableAutoConfiguration
    @ComponentScan(excludeFilters = {
            @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
            @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
    public @interface SpringBootApplication {

      公司里每个应用要本地启动的话,要在idea里这么配置

      

  • 相关阅读:
    搭建Flask+Vue及配置Vue 基础路由
    vue dev 环境下的跨域访问
    vue 调用常量的config.js文件
    PyCharm 通过Github和Git上管理代码
    MongoDB 配置服务
    2018年11月12日
    搭建 flask 应用
    Python 错误总结
    搭建 Django 平台
    go实现主线程等待子线程都运行完再退出
  • 原文地址:https://www.cnblogs.com/juniorMa/p/15131309.html
Copyright © 2011-2022 走看看