码迷,mamicode.com
首页 > 编程语言 > 详细

spring boot 启动脚本

时间:2019-01-15 20:00:45      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:post   ice   classpath   main   spring   ack   初始化   就会   const   

启动的时候 在 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 启动脚本

标签:post   ice   classpath   main   spring   ack   初始化   就会   const   

原文地址:https://www.cnblogs.com/aspirant/p/10273928.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!