博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring4 常用注解
阅读量:4290 次
发布时间:2019-05-27

本文共 2264 字,大约阅读时间需要 7 分钟。

#spring-core-4.2.6.RELEASE.jar中

@AliasFor:
将此注解属性的值应用到另一个属性上或者另外注解的属性上

//注解内部有属性可以互相替换时public @interface ContextConfiguration {   @AliasFor("locations")   String[] value() default {};   @AliasFor("value")   String[] locations() default {};   // ...}//此注解包含另外一个注解时@ContextConfigurationpublic @interface MyTestConfig {     @AliasFor(annotation = ContextConfiguration.class, attribute = "locations")   String[] value() default {};   //...}

@Order:排序使用

相关类org.springframework.core.Ordered :规定Order的范围AnnotationAwareOrderComparator :排序一组有@Order的ObjectOrderUtils :获取对象的@Order值javax.annotation.Priority :与@Order可以互换

#spring-beans-4.2.6.RELEASE.jar

@Autowired

1.注解的字段的类型寻找该类型的实例bean,这种方式成为byType。使用AutowiredAnnotationBeanPostProcessor来处理 依赖注入2.@Resource默认按照名称注入,它使用的是CommonAnnotationBeanPostProcessor来处理依赖注入。

@Configurable

使用@Configurable时,注解中的autowire属性就可以让Spring来自动装配了: @Configurable(autowire=Autowire.BY_TYPE) 或者 @Configurable(autowire=Autowire.BY_NAME,这样就可以按类型或者按名字自动装配了。BeanWiringInfoResolver解析

@Lookup

//todo

@Qualifier

@Autowired结合@Qualifier("XX")使用,让@Autowired按照byName方式装配。eg:@Autowired@Qualifier("userDAO")private UserDAO userDao;

@Required

依赖检查:必须含有注入值

@Value

用于注入SpEL表达式,可以放置在字段方法或参数上。

#spring-context-4.2.6.RELEASE.jar

##cache
Cacheable
CacheConfig
CacheEvict
CachePut
Caching
EnableCaching

##context

Bean
ComponentScan
Conditional
Configuration
DependsOn
Description
EnableAspectJAutoProxy
EnableLoadTimeWeaving
EnableMBeanExport
@Import
用在@Configuration配置类上
引入配置类或者一个Bean

@ImportResource

用在@Configuration配置类上 ,引入配置文件

@Lazy

懒加载

Primary

Profile
PropertySource
PropertySources
Role
Scope
##event
EventListener
##format
DateTimeFormat
NumberFormat
##scheduling
Async
EnableAsync
EnableScheduling
Scheduled
Schedules
##stereotype
Component
Controller
Repository
Service
##validation
Validated

#spring-aspects-4.2.6.RELEASE.jar

EnableSpringConfigured

#spring-tx-4.2.6.RELEASE.jar

EnableTransactionManagement
Transactional

#spring-web-4.2.6.RELEASE.jar

##web.bind

ControllerAdvice
CookieValue
CrossOrigin
ExceptionHandler
InitBinder
Mapping
MatrixVariable
ModelAttribute
PathVariable
RequestBody
RequestHeader
RequestMapping
RequestParam
RequestPart
ResponseBody
ResponseStatus
RestController
SessionAttributes
#spring-webmvc-4.2.6.RELEASE.jar
##config
EnableWebMvc

转载地址:http://pihgi.baihongyu.com/

你可能感兴趣的文章
sipp命令 各参数含义
查看>>
搜集的动植物分类、检索网站
查看>>
ffmpeg源码分析之媒体打开过程
查看>>
Ubuntu/centos/redhat/SUSE sipp安装(带rtp支持,3.5.1版本)
查看>>
周鸿祎:很多程序员聪明,但我一看就知道他不会成功
查看>>
编译程序遇到问题 relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;
查看>>
Const指针 、 指向const的指针 、引用、指针
查看>>
GDB调试命令
查看>>
常见数据类型的字节数
查看>>
gcc/g++ 编译常见问题
查看>>
【设计模式】 工厂模式实例 C++ , 利用工厂模式写一个计算器
查看>>
opencv
查看>>
【图像处理】 一、OSTU分割
查看>>
Android常用的框架有哪些
查看>>
SSL 证书创建与部署
查看>>
学习搭建人工智能环境遇到的问题
查看>>
自己编写的计算器
查看>>
视频物体检测
查看>>
Tomcat启动遇到的问题
查看>>
Gradle-gradlew
查看>>