1.启动类继承CommandLineRunner接口

2.如果预先加载多个用@Order(value=1) value=加载等级   等级数越小优先级越大

  例 

package com.example.demo;

import com.example.demo.controller.NettyClient;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

//实现CommandLineRunner @SpringBootApplication
public class DemoApplication implements CommandLineRunner { private static final Logger log = LoggerFactory.getLogger(DemoApplication.class); public static void main(String[] args) { SpringApplication app = new SpringApplication(DemoApplication.class); app.run(args); } @Override public void run(String... args) throws Exception { } }

相关文章:

  • 2022-12-23
  • 2021-07-30
  • 2021-08-07
  • 2022-01-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2021-12-29
  • 2021-11-24
  • 2022-12-23
  • 2022-01-19
  • 2021-10-27
  • 2021-04-18
相关资源
相似解决方案