方法:实现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项目: