springboot项目在启动的时候自动执行一段代码

方法:实现CommandLineRunner接口

package org.springeos.modules.Scheduled.util;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author liqiang
 * @date 2020/6/1 16:44
 * @param
 * @return
 * 说明:
 */


@Component
public class CommandLineRunnerImpl implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        System.out.println("springboot项目启动的时候执行的代码---------------------------------");

    }
}

启动springboot项目:
在这里插入图片描述


版权声明:本文为qq_43173523原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。