听说你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

 

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