聽說你SpringBoot用得賊溜,那麼相關注解你又知多少(持續更新)

目錄

Spring的Annotation

org.springframework.stereotype包下

org.springframework.beans.factory.annotation包下

org.springframework.context.annotation包下

org.springframework.validation.annotation包下

org.springframework.scheduling.annotation包下

org.springframework.cache.annotation包下

org.springframework.web.bind.annotation

javax.annotation

javax.validation


 

我整理了下常用的spring boot的註解腦圖

Spring的Annotation

  • org.springframework.stereotype包下

    • @Component   泛指所有組件
      • @Controller  控制器組件
      • @Reposity  數據訪問組件,如DAO層
      • @Service  業務處理層組件
    • @Indexed   註解添加索引,以提升應用啓動性能
  • org.springframework.beans.factory.annotation包下

    • @Autowired   自動注入類、方法、構造函數
      • 按照類去匹配,配合 @Qualifier 指定按照名稱去裝配 bean。
    • @Configurable  非Spring管理的類中使用依賴注入
      • https://blog.csdn.net/u013066244/article/details/89061676
    • @Value  將外部的值動態注入到Bean中
      • https://www.cnblogs.com/wangbin2188/p/9014837.html
    • @Lookup  方法注入
      • https://www.jb51.net/article/140402.htm
    • @Qualifier   通過這個標示,表明了哪個實現類纔是我們所需要的
      • https://blog.csdn.net/qq_36567005/article/details/80611139
      • https://www.cnblogs.com/chenxiaoxian/p/9760032.html
  • org.springframework.context.annotation包下

    • @Configuration   表示這個類可以使用 Spring IoC 容器作爲 bean 定義的來源
      • https://www.cnblogs.com/Guhongying/p/10600795.html
    • @Bean   該對象應該被註冊爲在 Spring 應用程序上下文中的 bean
      • https://www.cnblogs.com/feiyu127/p/7700090.html
    • @ComponentScan  定義掃描的路徑從中找出標識了需要裝配的類自動裝配到spring的bean容器中
      • https://www.cnblogs.com/jpfss/p/11171655.html
    • @Scope  作用域,在 Spring IoC 容器中具有以下幾種作用域:基本作用域singleton(單例)、prototype(多例)
      • https://www.cnblogs.com/nemowang1996/p/11195266.html
    • @PropertySource
    • @Lazy
    • @Import
  • org.springframework.validation.annotation包下

    • @Validated
  • org.springframework.scheduling.annotation包下

    • @Async
    • @EnableAsync
    • @EnableScheduling
    • @Scheduled
    • @Schedules
  • org.springframework.cache.annotation包下

    • @Cacheable
    • @CacheConfig
    • @CacheEvict
    • @CachePut
    • @Caching
    • @EnableCaching
  • org.springframework.web.bind.annotation

    • @Mapping
      • @RequestMapping  通用請求註解
        • @PostMapping  POST請求註解
        • @GetMapping   GET請求註解
        • @PutMapping   PUT請求註解
        • @DeleteMapping  Delete請求註解
        • @PatchMapping
    • @ModelAttribute
    • @PathVariable
    • @RequestAttribute
    • @RequestBody
    • @RequestMethod
    • @RequestParam
    • @ResponseBody
    • @RestController
    • @RestControllerAdvice
    • @ControllerAdvice
    • @ExceptionHandler
  • javax.annotation

    • @Generated
    • @PostConstruct
    • @PreDestroy
    • @Resource
    • @Resources
    • javax.annotation.security
      • @DeclareRoles
      • @DenyAll
      • @PermitAll
      • @RolesAllowed
      • @RunAs
    • javax.annotation.sql
      • @DataSourceDefinition
  • javax.validation

    • @Constraint
    • @Valid
    • @OverridesAttribute
    • javax.validation.constraints
      • @AssertFalse & AssertTrue
      • @DecimalMax & DecimalMin
      • @DecimalMin
      • @Digits
      • @Email
      • @Future & @FutureOrPresent
      • @Max  &  @Min
      • @Negetive  & NegativeOrZero
      • @Positive  &  @PositiveOrZero
      • @NotBlank & @NotEmpty &  @NotNull  & @Null
      • @Past &  @PastOrPresent
      • @Pattern
      • @Size

 

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