一、註解(annotations)列表
@SpringBootApplication:
包含了@ComponentScan、@Configuration和@EnableAutoConfiguration註解。
其中@ComponentScan讓spring Boot掃描到Configuration類並把它加入到程序上下文。
home.php?mod=space&uid=1414569 等同於spring的XML配置文件;使用Java代碼可以檢查類型安全。
@EnableAutoConfiguration 自動配置。
@ComponentScan 組件掃描,可自動發現和裝配一些Bean。
@Component可配合CommandLineRunner使用,在程序啓動後執行一些基礎任務。
@RestController註解是@Controller和@ResponseBody的合集,表示這是個控制器bean,並且是將函數的返回值直 接填入HTTP響應體中,是REST風格的控制器。
@Autowired自動導入。
@PathVariable獲取參數。
@JsonBackReference解決嵌套外鏈問題。
@RepositoryRestResourcepublic配合spring-boot-starter-data-rest使用。
二、註解(annotations)詳解
@SpringBootApplication:申明讓spring boot自動給程序進行必要的配置,這個配置等同於:@Configuration ,@EnableAutoConfiguration 和 @ComponentScan 三個配置。
```package com.example.myproject;
import org.springframework.boot.SpringApplication;
import or