1. 程式人生 > >spring boot 啟動腳本

spring boot 啟動腳本

span top ostc struct bin owa oid cef row

啟動的時候 在 boot_class 中有個:com.sankuai.qcs.regulation.shanghai.App 這是spring boot的配置,在 bin/run_main.sh中 有配置:

${EXEC_JAVA} ${boot_class}  2>&1

這樣在啟動的時候就會走:方法:
com.sankuai.qcs.regulation.shanghai.App;
裏面的main方法;

在main裏面有個:
classpath:application.xml;

在application.xml中有個:添加了註解的標簽:
<task:annotation-driven/>

所以開始使用註解初始化:
com.sankuai.qcs.regulation.shanghai.service.impl;裏面的方法:
  @PostConstruct
    private void start() {
        try {
            Properties successTopicProps = new Properties();
            successTopicProps.setProperty(ConsumerConstants.MafkaBGNamespace, "waimai");
            successTopicProps.setProperty(ConsumerConstants.MafkaClientAppkey, 
"com.sankuai.qcs.data.integration"); callBackProducer = MafkaClient.buildProduceFactory(successTopicProps, "dache.regulation.traffic.data"); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public
void run() { batchSendTask(); } }, 1000, 1000); } catch (Throwable throwable) { LOGGER.error("BatchSendService#start init mafka producer error", throwable); } }

請註意前面有個:

@PostConstruct 它的意思是在加載bean的時候就開始 先執行方法:
start

spring boot 啟動腳本