Spring Boot 设置启动加载方法

实现这个接口之后一启动就会加载

package com.cloudtech.demo;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
 
import com.cloudtech.web.dao.FieldConfigMapper;
import com.cloudtech.web.dao.RuleCodeMapper;
 
@SpringBootApplication
@ComponentScan(value = {"*.*.*"})
public class DemoApplication implements CommandLineRunner{
	@Autowired
	private FieldConfigMapper fieldConfigMapper;
	@Autowired
	private RuleCodeMapper ruleCodeMapper;
 
	public static void main(String[] args) {
		//SpringApplication.run(DemoApplication.class, args);
		new SpringApplicationBuilder(DemoApplication.class)
		    .web(WebApplicationType.NONE)
		    .run(args);
	}
 
	@Override
	public void run(String... args) throws Exception {
		
	}
}

发布了40 篇原创文章 · 获赞 53 · 访问量 7717

猜你喜欢

转载自blog.csdn.net/qq_44758351/article/details/104184268
今日推荐