版权声明: https://blog.csdn.net/qq_32157851/article/details/80679830
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class MystartRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("<<<<<<<<<<<<这个是测试CommandLineRunn接口>>>>>>>>>>>>>>");
}
}
1)新建一个类实现CommandLineRunner接口,
2)在类上打一个@Component的注解
3)将要执行的方法写入到run方法中去