1. 程式人生 > >springBoot(2)註解解釋

springBoot(2)註解解釋

pub pri 允許 rest .class oot tap json格式 col

@EnableAutoConfiguration:啟用springboot的自動配置,根據所聲明的依賴對Spring進行自動配置

@ComponentScan  和  @Component在應用程序所在的程序包上啟用掃描

@Configuration:允許在上下文中註冊額外的bean或導入其他配置類

@RestController:標記該controller反會json格式,用來直接編寫Restful接口

@SpringBootApplication:標記為啟動類

使用ComponentScanEnableAutoConfiguration代替SpringBootApplication啟動

@ComponentScan(basePackages = "com.test.run")//---控制器掃包範圍
@EnableAutoConfiguration
public class App {
	public static void main(String[] args) {
		SpringApplication.run(App.class, args);
	}
}

  

springBoot(2)註解解釋