SpringBoot:第五篇 CommandLineRunner

实现应用启动的时候初始化或者调用

package com.example.demo.init;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
* @author duanxiaoqiu
* @Date 2019-06-17 20:12
**/
@Slf4j
@Component
public class initData implements CommandLineRunner {


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

}
}

 

@Order(value=0) 实现先后循序

package com.example.demo.init;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
* @author duanxiaoqiu
* @Date 2019-06-17 20:12
**/
@Slf4j
@Order(value = 0)
@Component
public class initData implements CommandLineRunner {


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

}
}

 

posted @ 2019-06-17 20:25  诸葛子房  阅读(193)  评论(0编辑  收藏  举报