本文共 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
@Autowired1.注解的字段的类型寻找该类型的实例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/