SpringBoot註解

SpringBoot註解

一、聲明bean註解

1@Component通用註解
2@Controller表現層
3@Service業務邏輯層
4@Repository數據訪問層(dao層)
5@RestController表現層,@Controller+@ResponseBody


二、注入bean註解

1@Resource
2@Autowiredspring提供
3@Inject


三、bean作用域、bean生命週期註解

1、bean的作用域

1@Scope


  1) singleton :單例,spring默認配置,一個spring容器中只有一個bean的實例,全容器共享一個實例。

  2) Prototpe :多實例,每次調用創建一個bean實例

  3) Request :

  4) Session :

  5) GlobalSession :


2、bean的生命週期

1

2



四、main方法入口註解

1@SpringBootApplication


1

2

3


五、aop註解

1

2

3

4












一、Controller層

1@SpringBoorApplicationspringboot啓動註解
2@configurationspringboot
3@EnableAutoConfiguration
4@RestControllercontroller層註解,相當於@ResponseBody和@Controller的組合註解
5@Controllercontroller層註解
6@ResponseBody返回json格式,與@Controller搭配使用
7@RequestMapping請求路徑限制
8@RequestParam讀取請求參數
9



二、Service層

1@Serviceservice層註解
2@Autowired自動裝配
3@Resource注入對象之間的關係
4@Value



三、持久層

@Mapper
   @Repository

1@MapperDao層註解
2@Query
3@Param
4



四、表的映射

1@Entity實體類註解
2@Table表名
3@Id表中的id
4@Transient



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章