zoukankan      html  css  js  c++  java
  • spingboot启动时运行

    spingboot启动时运行

    通过实现接口 CommandLineRunner 来实现

    package com.hisfront.vh.init;
    
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.core.annotation.Order;
    import org.springframework.stereotype.Component;
    
    /**
     * @file_name:Init1.java
     * @description:
     *
     * @time:2018年5月18日 上午9:56:27
     * @author:sf
     */
    @Component
    @Order(value = 1)
    public class Init1 implements CommandLineRunner {
    
    	@Override
    	public void run(String... args) throws Exception {
    		// TODO Auto-generated method stub
    		System.out.println("============> value=1");
    	}
    }
    
    
    package com.hisfront.vh.init;
    
    import org.springframework.boot.CommandLineRunner;
    import org.springframework.core.annotation.Order;
    import org.springframework.stereotype.Component;
    
    /**
     * @file_name:Init2.java
     * @description:
     *
     * @time:2018年5月18日 上午9:56:27
     * @author:sf
     */
    @Component
    @Order(value = 2)
    public class Init2 implements CommandLineRunner {
    
    	@Override
    	public void run(String... args) throws Exception {
    		// TODO Auto-generated method stub
    		System.out.println("============> value=2");
    	}
    }
    
    

    效果

    ============> value=1
    ============> value=2
    
  • 相关阅读:
    宠物小精灵之收服(dp)
    装箱问题(dp)
    背包问题(采药)
    导弹防御系统(dfs+贪心)
    2018091-2 博客作业
    第一周例行报告
    洛谷 P6378 [PA2010]Riddle
    洛谷 P5782 [POI2001]和平委员会
    洛谷 P3825 [NOI2017]游戏
    POJ 3683 Priest John's Busiest Day
  • 原文地址:https://www.cnblogs.com/vmkash/p/9055248.html
Copyright © 2011-2022 走看看