欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

springboot CommandLineRunner ApplicationRunner

程序员文章站 2022-03-01 20:10:24
...

package com.anyec.demo;

 

import org.springframework.boot.ApplicationArguments;

import org.springframework.boot.ApplicationRunner;

import org.springframework.boot.CommandLineRunner;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.SpringApplicationRunListener;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.ApplicationEvent;

import org.springframework.context.ApplicationListener;

 

@SpringBootApplication

public class DemoApplication implements ApplicationListener<ApplicationEvent>,CommandLineRunner,

ApplicationRunner,SpringApplicationRunListener{

 

public static void main(String[] args) {

SpringApplication.run(DemoApplication.class, args);

}

 

@Override

public void onApplicationEvent(ApplicationEvent event) {//ApplicationListener

 

}

 

@Override

public void run(String... args) throws Exception {//CommandLineRunner

 

}

 

@Override

public void run(ApplicationArguments args) throws Exception {//ApplicationRunner

 

}

 

}