文章分类 -  spring

spring 手动注册bean
摘要://将applicationContext转换为ConfigurableApplicationContext ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) SpringContextUtil.getApplicationContext(); // ... 阅读全文

posted @ 2018-10-09 11:43 腾飞的鹰 阅读(2381) 评论(0) 推荐(0)

Spring 与代理有关属性详解
摘要:但是知道proxy-target-class 以及 expose-proxy 属性的作用吗? proxy-target-class: 强调spring 应该使用那种代理方式:JDK动态代理和CGLIB 强制使用CGLIB代理会出现以下问题 无法通知Final方法,因为他们不能被覆写 另外还需要将CG 阅读全文

posted @ 2018-09-07 17:22 腾飞的鹰 阅读(269) 评论(0) 推荐(0)

深入Spring:自定义事务管理
摘要:Spring的开启事务管理主要是通过@EnableTransactionManagement注解来实现的。 查看源码就会发现,这个注解主要是注入了两个类InfrastructureAdvisorAutoProxyCreator和BeanFactoryTransactionAttributeSourc 阅读全文

posted @ 2018-09-07 17:14 腾飞的鹰 阅读(2191) 评论(0) 推荐(0)

使用DefaultAdvisorAutoProxyCreator创建代理
摘要:根据spring-framework-reference,DefaultAdvisorAutoProxyCreator创建代理更加通用强大,使用此机制包括:a.指定一个DefaultAdvisorAutoProxyCreator Bean的定义.b.指定在相同或相关的上下文中任意数量的Advisor 阅读全文

posted @ 2018-09-07 17:08 腾飞的鹰 阅读(1127) 评论(0) 推荐(0)

使用BeanNameAutoProxyCreator创建代理
摘要:BeanNameAutoProxyCreator是自动代理创建器的三种(BeanNameAutoProxyCreator,DefaultAdvisorAutoProxyCreator,AbstractAdvisorAutoProxyCreator)之一.它是根据拦截器和设置的Bean的名称表达式做匹 阅读全文

posted @ 2018-09-07 17:06 腾飞的鹰 阅读(1448) 评论(1) 推荐(0)

annotation-config, annotation-driven, compont-scan 区别
摘要:本文开门见山,直接分别进行解释: 一、<context:annotation-config/> 隐式地向Spring容器中注册AutowiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor、PersistenceAnnot 阅读全文

posted @ 2018-09-07 17:02 腾飞的鹰 阅读(78) 评论(0) 推荐(0)

自定义BeanDefinitionRegistryPostProcessor
摘要:原文地址:https://blog.csdn.net/elim168/article/details/78056446 BeanDefinitionRegistryPostProcessor继承自BeanFactoryPostProcessor,是一种比较特殊的BeanFactoryPostProc 阅读全文

posted @ 2018-08-22 21:14 腾飞的鹰 阅读(468) 评论(1) 推荐(0)

<context:component-scan>详解
摘要:默认情况下,<context:component-scan>查找使用构造型(stereotype)注解所标注的类,如@Component(组件),@Service(服务),@Controller(控制器),@Repository(数据仓库) 我们具体看下<context:component-scan 阅读全文

posted @ 2018-08-22 20:22 腾飞的鹰 阅读(420) 评论(0) 推荐(0)

定义切面使用@Aspect、@EnableAspectJAutoProxy、<aop:aspectj-autoproxy>
摘要:一、 假设有如下情况,有一个演凑者和一批观众,要实现在演凑者的演凑方法前织入观众的"坐下"、"关手机方法",在演凑结束后,如果成功,则织入观众"鼓掌",演凑出错则观众要求"回水" 基本的类如下: 1. 2. 3. 4. 二、 可以定义的advice Spring的切面是一个pojo 1.使用@Asp 阅读全文

posted @ 2018-06-09 18:22 腾飞的鹰 阅读(3918) 评论(0) 推荐(0)

给BEAN运行时注入值placeholder、@Value
摘要:一、用placeholder给bean运行时注入值的步骤 Spring取得placeholder的值是用${...} 1.声明placeholder bean (1)java方式 (2)xml方式 2.注入 1.在java文件中用 @Value 如构造函数 阅读全文

posted @ 2018-06-09 17:49 腾飞的鹰 阅读(405) 评论(0) 推荐(0)

给bean运行时注入值(Environment,Property文件)
摘要:一、 直观的给bean注入值如下: @Bean public CompactDisc sgtPeppers() { return new BlankDisc( "Sgt. Pepper's Lonely Hearts Club Band", "The Beatles"); } @Bean publi 阅读全文

posted @ 2018-06-09 17:37 腾飞的鹰 阅读(368) 评论(0) 推荐(0)

Bean的作用域@Scope、ProxyMode
摘要:原文地址:https://www.cnblogs.com/shamgod/p/5236060.html 一、 Spring的bean默认是单例的 二、@Scope的三种用法 1.在自动扫描中 2.在java配置文件中 @Bean @Scope(ConfigurableBeanFactory.SCOP 阅读全文

posted @ 2018-06-09 17:30 腾飞的鹰 阅读(4223) 评论(0) 推荐(0)

Spring PropertyPlaceholderConfigurer 自定义扩展
摘要:原文地址:https://blog.csdn.net/feiyu8607/article/details/8282893 Spring中PropertyPlaceholderConfigurer这个类,它是用来解析Java Properties属性文件值,并提供在spring配置期间替换使用属性值。 阅读全文

posted @ 2018-06-09 16:55 腾飞的鹰 阅读(1358) 评论(0) 推荐(0)

Spring中Ordered接口简介
摘要:目录 前言 Ordered接口介绍 Ordered接口在Spring中的使用 总结 前言 Spring中提供了一个Ordered接口。Ordered接口,顾名思义,就是用来排序的。 Spring是一个大量使用策略设计模式的框架,这意味着有很多相同接口的实现类,那么必定会有优先级的问题。 于是,Spr 阅读全文

posted @ 2018-06-09 16:35 腾飞的鹰 阅读(413) 评论(0) 推荐(0)

Spring AOP @Before @Around @After 等 advice 的执行顺序
摘要:用过spring框架进行开发的人,多多少少会使用过它的AOP功能,都知道有@Before、@Around和@After等advice。最近,为了实现项目中的输出日志和权限控制这两个需求,我也使用到了AOP功能。我使用到了@Before、@Around这两个advice。但在,使用过程中,却对它们的执 阅读全文

posted @ 2018-06-09 16:13 腾飞的鹰 阅读(270) 评论(0) 推荐(0)

pring bean 通过实现 InitializingBean ,DisposableBean 接口实现初始化方法和销毁前操作
摘要:关于在spring 容器初始化 bean 和销毁前所做的操作定义方式有三种: 第一种:通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作 第二种是:通过 在xml中定义init-method 和 destory-method方法 第三种是: 通 阅读全文

posted @ 2018-06-09 15:47 腾飞的鹰 阅读(113) 评论(0) 推荐(0)

Spring(三) Bean继续入门
摘要:一、Aware相关接口 对于应用程序来说,应该尽量减少对Sping Api的耦合程度,然而有些时候为了运用Spring所提供的一些功能,有必要让Bean了解Spring容器对其进行管理的细节信息,如让Bean知道在容器中是以那个名称被管理的,或者让Bean知道BeanFactory或者Applica 阅读全文

posted @ 2018-06-08 18:14 腾飞的鹰 阅读(110) 评论(0) 推荐(0)

spring之BeanFactoryAware接口
摘要:要直接在自己的代码中读取spring的bean,我们除了根据常用的set外,也可以通过spring的BeanFactoryAware接口实现,只要实现setBeanFactory方法就可以, 这样我们就可以直接拿东西用了,如 Object object = beanFactory.getBean(b 阅读全文

posted @ 2018-06-08 18:01 腾飞的鹰 阅读(4293) 评论(0) 推荐(0)

spring源码(11)bean的parent属性详解和获取RootBeanDefinition
摘要:原文地址:https://blog.csdn.net/disiwei1012/article/details/77142167 一、bean标签的parent属性 该节详细介绍了 bean的继承关系(bean标签的parent属性),下面简单翻译一下: 我们知道,BeanDefinition是 be 阅读全文

posted @ 2018-06-08 17:51 腾飞的鹰 阅读(651) 评论(0) 推荐(0)

【Spring4揭秘 BeanFactory】基本容器-BeanFactory
摘要:原文地址:https://blog.csdn.net/u011179993/article/details/51636742 控制反转即IoC (Inversion of Control),它把传统上由程序代码直接操控的对象的调用权交给容器,通过容器来实现对象组件的装配和管理。所谓的“控制反转”概念 阅读全文

posted @ 2018-06-08 17:01 腾飞的鹰 阅读(168) 评论(0) 推荐(0)

导航