SpringBoot 启动时加载类 ApplicationRunner 和 CommandLineRunner

ApplicationRunner默认先于CommandLineRunner执行

package pers.wilson;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 
 */
@Component
public class InitLoadModuleComponent implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) throws Exception {

    }
}
package pers.wilson;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 
 */
@Component
public class InitLoadModuleComponent implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {

    }
}

你可能感兴趣的:(SpringBoot 启动时加载类 ApplicationRunner 和 CommandLineRunner)