美文网首页
spring-boot 启动的同时执行代码

spring-boot 启动的同时执行代码

作者: jerrybw | 来源:发表于2017-08-23 15:24 被阅读0次

只需要写一个类继承CommandLineRunner然后实现run方法,run方法即会在此项目启动时执行

package com.jerry.work.runner;

import com.jerry.work.reminder.Reminder;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 
 */
@Component
@Order(value=1)
public class StartupRunner implements CommandLineRunner
{
    @Override
    public void run(String... args) throws Exception
    {
        System.out.println("启动springboot");
    }
}

相关文章

网友评论

      本文标题:spring-boot 启动的同时执行代码

      本文链接:https://www.haomeiwen.com/subject/bdnddxtx.html