? ? @Value 從配置文件讀取參數(shù)
? ? @ConfigurationProperties 把yml里面一組配置參數(shù)封裝成一個類
? ? @Component 向SpringBoot注冊一個類
? ? @Controller? 處理Http請求
? ? @RestController 相當(dāng)于@Controller+@ResponseBody
? ? @RequestMapping 配置url映射
? ? @ControllerAdvice? +@ExceptionHandler(value = Exception.class) 捕獲異常? (用于統(tǒng)一異常處理)
? ? 如果不用@ControllerAdvice,就只能在當(dāng)前controller里捕獲異常,@ControllerAdvice可以擺脫這個限制
? ? @PathVariable? 獲取url中的數(shù)據(jù)? /100? (獲取詳細(xì)信息)
? ? @RequestParam? 獲取請求參數(shù)的值 ?id=100
? ? @GetMapping? ? 組合注解? 相當(dāng)于 @RequestMapping(method = RequestMethod.GET)?
? ? jpa.hibernate.ddl-auto:creat、update、none、creat-drop、validate
? ? ? ? ? ? ? ? ? ? ? ? ?creat每次運(yùn)行時,都會創(chuàng)建新表(若有,刪除原有的,在建新的),
? ? ? ? ? ? ? ? ? ? ? ? ?update不會刪除原有的,保留改變的,更新,create-drop不運(yùn)行時,刪表,
? ? ? ? ? ? ? ? ? ? ? ? ?none什么也不作,
? ? ? ? ? ? ? ? ? ? ? ? validate驗(yàn)證類里面屬性是否與表結(jié)構(gòu)一致,不一致報(bào)錯;
? ? @Valid? 表單驗(yàn)證在Controller層加上@valid,后緊跟BindingResult,通過 BingdingResult.getFieId.getDefaultMessage()獲取錯誤信息,
? ? 表單? ?驗(yàn)證注解:@Min。。。。。。。等等
? ? @Pointcut注解聲明切入點(diǎn)
? ? @Before @After 兩注解直接復(fù)用該方法切入點(diǎn) @Pointcut 是切點(diǎn) @Before和@After 中調(diào)用相同方法是切面? 把切點(diǎn)放入到切面中就是織入? ? ? ? ? 這是aop的思想? 面向切面編程
? ? @AfterReturning? aop中用@AfterReturning獲取返回的內(nèi)容
? ? ?spring只會針對RuntimeException進(jìn)行回滾,而不會對Exception進(jìn)行回滾,使用注解@Controlleradvice
? ?@Configuration把一個類作為一個IoC容器,它的某個方法頭上如果注冊了@Bean,就會作為這個Spring容器中的Bean。
? ?@Scope注解 作用域
? ?@Lazy(true) 表示延遲初始化
? ?@Service用于標(biāo)注業(yè)務(wù)層組件、
? ?@Controller用于標(biāo)注控制層組件(如struts中的action)
? ?@Repository用于標(biāo)注數(shù)據(jù)訪問組件,即DAO組件。
? ?@Component泛指組件,當(dāng)組件不好歸類的時候,我們可以使用這個注解進(jìn)行標(biāo)注。
? ?@Scope用于指定scope作用域的(用在類上)
? ?@PathVariable
? ? 如果映射名稱有所不一,可以參考如下方式:?
? ? @RequestMapping(value?=?"/person/profile/{id}",?method?=?RequestMethod.GET)??
? ? public?@ResponseBody??
? ? Person?porfile(@PathVariable("id")?int?uid)?{??
?? ??return?new?Person(uid,?name,?status);??
? ? }??