SpringBoot啓動方式
1.springboot使用啓動類啓動,SpringBoot可以java方式啓動項目
編寫啓動類:
@SpringBootApplication
public class myspringboot{
public static void main(String[] args){
SpringApplication.run(App.class,args);
}
}
main方法:裏面寫SpringApplication.run(類名.class,args);
註解: 1:@EnableAutoConfiguration註解
掃描本類Controller
2:@ComponentScan註解
掃描指定包的Controller
掃描多個包的Controller
@ComponentScan(basePackages={"com.fyl.test.controller","com.fyl.test.controller2}
3:@SpringBootApplication註解(重點)
SpringBootApplicationd等於@EnableAutoConfiguration+@ComponentScan :用於掃描同級包(包含子包)和當前包,所以啓動和其他類包在同一級別
2.maven項目Springboot插件啓動