spring boot設定方法一啟動就開始載入
阿新 • • 發佈:2018-11-07
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 { } }
實現這個介面就可以了