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里这么配置

      

  • 相关阅读:
    网页设计太麻烦?15款免费优质Bootstrap UI工具包助你效率倍增!
    【自古套路得人心】最全UI图表设计技巧和套路,分分钟打造最优设计
    原型对接工作流!摹客全面支持Axure原型
    赶紧收藏!41个Web UI工具包资源免费及付费下载
    2019年设计师必看,UI加载动画完全解读
    845G
    845G
    845D
    845C
    845B
  • 原文地址:https://www.cnblogs.com/juniorMa/p/15131309.html
Copyright © 2011-2022 走看看