zoukankan      html  css  js  c++  java
  • spring注解总结,spring注解大全

    基于 springframework 4.3.8  总结了部分注解,欢迎指点补充。

    1spring-context
    org.springframework.scheduling.annotation.Schedules 多个定时
    org.springframework.scheduling.annotation.EnableScheduling 开启对计划任务的支持
    org.springframework.scheduling.annotation.Async
    org.springframework.scheduling.annotation.Scheduled 定时器表达式
    org.springframework.scheduling.annotation.EnableAsync
    org.springframework.context.annotation.Lazy
    org.springframework.context.annotation.ImportResource
    org.springframework.context.annotation.EnableLoadTimeWeaving
    org.springframework.context.annotation.PropertySource
    org.springframework.context.annotation.Import
    org.springframework.context.annotation.Scope 域
    org.springframework.context.annotation.Configuration
    org.springframework.context.annotation.Description
    org.springframework.context.annotation.Bean 加到容器的bean
    org.springframework.context.annotation.DependsOn 该bean需要依赖某个bean
    org.springframework.context.annotation.Role
    org.springframework.context.annotation.PropertySources
    org.springframework.context.annotation.Profile 处理不同环境 prod dev
    org.springframework.context.annotation.Primary 有多个接口实现时,没有指定实现,使用主要实现
    org.springframework.context.annotation.EnableAspectJAutoProxy
    org.springframework.context.annotation.Conditional
    org.springframework.context.annotation.ComponentScan 扫描包
    org.springframework.context.annotation.EnableMBeanExport
    org.springframework.context.event.EventListener
    org.springframework.validation.annotation.Validated
    org.springframework.jmx.export.annotation.ManagedResource
    org.springframework.jmx.export.annotation.ManagedNotification
    org.springframework.jmx.export.annotation.ManagedOperationParameter
    org.springframework.jmx.export.annotation.ManagedOperation
    org.springframework.jmx.export.annotation.ManagedNotifications
    org.springframework.jmx.export.annotation.ManagedAttribute
    org.springframework.jmx.export.annotation.ManagedMetric
    org.springframework.jmx.export.annotation.ManagedOperationParameters
    org.springframework.cache.annotation.Caching 缓存管理 ehcache
    org.springframework.cache.annotation.CacheEvict  根据key删除
    org.springframework.cache.annotation.EnableCaching 开启对缓存的支持
    org.springframework.cache.annotation.Cacheable
    org.springframework.cache.annotation.CachePut  添加
    org.springframework.cache.annotation.CacheConfig
    org.springframework.format.annotation.NumberFormat 时间格式化
    org.springframework.format.annotation.DateTimeFormat 日期格式化,添加到entity成员变量
    org.springframework.stereotype.Controller 基于Component 控制层
    org.springframework.stereotype.Repository 基于Component 持久层
    org.springframework.stereotype.Service 基于Component 服务层
    org.springframework.stereotype.Component 被扫描到容器


    2spring-web
    org.springframework.web.bind.annotation.CrossOrigin 支持跨域
    org.springframework.web.bind.annotation.RequestHeader 可以把Request请求header部分的值绑定到方法的参数上。
    org.springframework.web.bind.annotation.RequestParam 将请求参数区数据映射到功能处理方法的参数上
    org.springframework.web.bind.annotation.ResponseStatus 返回一个状态,加在方法上
    org.springframework.web.bind.annotation.MatrixVariable 矩阵变量, url使用分号传值
    org.springframework.web.bind.annotation.ModelAttribute  在有ControllerAdvice注解的类里使用,在所有controller的RequestMapping方法前执行,在普通Controller类里,在本controller的RequestMapping方法前执行
    org.springframework.web.bind.annotation.ExceptionHandler 被ControllerAdvice注解过的类中的 方法上的注解 公共异常处理
    org.springframework.web.bind.annotation.CookieValue 可以把Request header中关于cookie的值绑定到方法的参数上。
    org.springframework.web.bind.annotation.PostMapping Mapping简写基于RequestMapping
    org.springframework.web.bind.annotation.RequestPart 绑定上传的文件
    org.springframework.web.bind.annotation.RequestMapping 基于Mapping 并配置 get post等参数
    org.springframework.web.bind.annotation.GetMapping Mapping简写基于RequestMapping
    org.springframework.web.bind.annotation.RequestBody 绑定请求的内容区数据并能进行自动类型转换,可以转json
    org.springframework.web.bind.annotation.InitBinder 初始化所有RequestMapping数据
    org.springframework.web.bind.annotation.PatchMapping Mapping简写基于RequestMapping
    org.springframework.web.bind.annotation.Mapping RequestMapping父注解
    org.springframework.web.bind.annotation.SessionAttribute 请求参数绑定到形参session域
    org.springframework.web.bind.annotation.RestController controller+ResponseBody
    org.springframework.web.bind.annotation.ControllerAdvice 作用在类上,内部含有InitBinder,ExceptionHandler,ModelAttribute等方法注解
    org.springframework.web.bind.annotation.SessionAttributes 请求参数绑定到形参session域
    org.springframework.web.bind.annotation.ResponseBody 异步返回到body
    org.springframework.web.bind.annotation.RestControllerAdvice ControllerAdvice+ResponseBody
    org.springframework.web.bind.annotation.RequestAttribute url参数绑定到形参
    org.springframework.web.bind.annotation.DeleteMapping Mapping简写基于RequestMapping
    org.springframework.web.bind.annotation.PutMapping Mapping简写基于RequestMapping
    org.springframework.web.bind.annotation.PathVariable 绑定URI模板变量值
    org.springframework.web.context.annotation.SessionScope 配合bean Component
    org.springframework.web.context.annotation.RequestScope 配合bean Component
    org.springframework.web.context.annotation.ApplicationScope 配合bean Component

    3spring-webmvc
    org.springframework.web.servlet.config.annotation.EnableWebMvc 开启springmvc支持

    4spring-beans
    org.springframework.beans.factory.annotation.Autowired 注入
    org.springframework.beans.factory.annotation.Configurable
    org.springframework.beans.factory.annotation.Required 被标注的set方法,必须赋值
    org.springframework.beans.factory.annotation.Lookup
    org.springframework.beans.factory.annotation.Value 赋值
    org.springframework.beans.factory.annotation.Qualifier 配合Autowired


    5 spring-tx 事物处理
    org.springframework.transaction.annotation.EnableTransactionManagement 开启事物
    org.springframework.transaction.annotation.Transactional 该方法支持事物
    org.springframework.transaction.event.TransactionalEventListener

  • 相关阅读:
    Android为TV端助力 转载:RecyclerView分页加载
    Android 最简单的测试UI卡顿
    Android为TV端助力 使用shared注意事项
    Android为TV端助力 电影栏目移动到底部或者顶部时抖动动画
    Android为TV端助力转载:码农小阿飞(SpannableString)
    Android为TV端助力 监听APK卸载,替换,完成的广播
    Android 为TV端助力
    Android为TV端助力 进制互相转换
    Android为TV端助力linux命令
    Android为TV端助力 集成第三方播放器,实现全屏播放
  • 原文地址:https://www.cnblogs.com/moncat/p/7234981.html
Copyright © 2011-2022 走看看