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

      

  • 相关阅读:
    数据恢复:模拟2个逻辑坏块
    Oracle Internal Event:10201 consistent read undo application诊断事件
    Enterprise Manager Cloud Control 12.1.0.1 (12c)安装指南
    Script:GoldenGate For Oracle数据库预检查脚本
    OGG常见初始化方案
    expdp+compression性能测试
    了解AMDU工具生成的MAP文件
    何时会发生db file sequential read等待事件?
    Oracle发布公共云Public Cloud
    Oracle Internal Research深入研究Oracle内部原理
  • 原文地址:https://www.cnblogs.com/juniorMa/p/15131309.html
Copyright © 2011-2022 走看看