spring boot设置方法一启动就开始加载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_16855077/article/details/82839532
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 = {"com.cloudtech"})
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 {
		
	}
}

实现这个接口就可以了

猜你喜欢

转载自blog.csdn.net/qq_16855077/article/details/82839532