InitRunner.java 910 字节
Newer Older
武汉红喜's avatar
武汉红喜 已提交
1
package org.hongxi.whatsmars.spring.boot.controller;
武汉红喜's avatar
武汉红喜 已提交
2

武汉红喜's avatar
@Async  
武汉红喜 已提交
3
import org.hongxi.whatsmars.spring.boot.async.MessageService;
武汉红喜's avatar
武汉红喜 已提交
4 5
import org.hongxi.whatsmars.spring.boot.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
武汉红喜's avatar
武汉红喜 已提交
6 7 8 9 10 11 12 13 14 15
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Created by shenhongxi on 2017/6/29.
 */
@Component
@Order(value = 1)
public class InitRunner implements CommandLineRunner {
武汉红喜's avatar
武汉红喜 已提交
16 17
    @Autowired
    private UserMapper userMapper;
武汉红喜's avatar
@Async  
武汉红喜 已提交
18 19
    @Autowired
    private MessageService messageService;
武汉红喜's avatar
武汉红喜 已提交
20

武汉红喜's avatar
武汉红喜 已提交
21 22
    @Override
    public void run(String... args) throws Exception {
武汉红喜's avatar
武汉红喜 已提交
23 24
        System.out.println("init......createIfNotExistsTable");
        userMapper.createIfNotExistsTable();
武汉红喜's avatar
@Async  
武汉红喜 已提交
25 26 27 28

        for (int i = 0; i < 10; i++) {
            messageService.send("message" + i);
        }
武汉红喜's avatar
武汉红喜 已提交
29 30
    }
}