學習筆記之springboot註解

2021-09-27 06:37:05 字數 744 閱讀 2255

2,@controller(程式入口)

import org.springframework.stereotype.controller;

處理請求位址對映,可以用在類或方法上。用於類上,表示類中的所有響應請求的方法都是以該位址作為父路徑。

4,@responsebody

import org.springframework.web.bind.annotation.responsebody;

5,@requestbody

該註解用於將controller的方法返回的物件,通過適當的httpmessageconverter轉換為指定格式後,寫入到response物件的body資料區。

import org.springframework.web.bind.annotation.requestbody;

7,@repository

可以確保dao或者repositories提供異常轉譯。

import org.springframework.stereotype.repository;

8,@autowired

自動匯入依賴的bean

import org.springframework.beans.factory.annotation.autowired;

9,service

修飾service層的元件

import org.springframework.stereotype.service;

spring boot 學習筆記

spring boot 學習筆記 1.有時候我們在專案啟動的時候,總是需要先啟動一些初始化的類,以前比較常見的做法是寫再static塊中,spring boot提供了乙個commandlinerunner介面,實現這個介面的類總是會被優先啟動,並優先執行commandlinerunner介面中提供的...

spring boot 學習筆記

本位參考 生成spring boot 工程,通過 spring boot 快速入門 spring boot 開發web 應用 spring boot工程結構推薦 spring boot構建restful api與單元測試 spring boot中使用swagger2構建強大的restful api文...

springboot學習筆記

restcontroller controller responsebody 控制器 value 從配置檔案中讀取元素值賦值 component 將類交給spring管理 請求引數 requestparam value id required false defaultvalue 0 請求字段 是否...