spring boot 启动脚本

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


然后在pom.xml中有个:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<plugin>
               <artifactId>maven-jar-plugin</artifactId>
               <version>2.3.2</version>
               <configuration>
                   <finalName>qcs.service.regulation</finalName>
                   <classesDirectory>target/classes/</classesDirectory>
                   <archive>
                       <addMavenDescriptor>false</addMavenDescriptor>
                       <manifest>
                           <mainClass>com.sankuai.qcs.regulation.shanghai.App</mainClass>
                           <addClasspath>true</addClasspath>
                           <classpathPrefix>lib/</classpathPrefix>
                       </manifest>
                   </archive>
               </configuration>
           </plugin>

  里面的mainClass指的是:这个插件在在打包的时候要调用mainClass;

 

 
posted @   aspirant  阅读(592)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2014-01-15 面试遇到的问题
2014-01-15 Spring学习14-源码下载地址
点击右上角即可分享
微信分享提示