方法一:
-
import org.springframework.boot.ApplicationArguments;
-
import org.springframework.boot.ApplicationRunner;
-
import org.springframework.stereotype.Component;
-
/**
-
* @Author: wzwsq
-
* @Date: 2020/12/9 9:31
-
* 该类用于在springboot启动之后加载
-
*/
-
@Component
-
public class ApplicationRunnerImpl implements ApplicationRunner {
-
@Override
-
public void run(ApplicationArguments args) throws Exception {
-
System.out.println("通过实现ApplicationRunner接口");
-
}
-
}
方法二:
-
import org.springframework.boot.CommandLineRunner;
-
import org.springframework.stereotype.Component;
-
/**
-
* @Author: wzwsq
-
* @Date: 2020/12/9 9:31
-
* 该类用于在springboot启动之后加载
-
*/
-
@Component
-
public class TestImplCommandLineRunner implements CommandLineRunner {
-
@Override
-
public void run(String... args) throws Exception {
-
System.out.println("<<<<<<<<<<<<这个是测试CommandLineRunn接口>>>>>>>>>>>>>>");
-
}
-
}