
Spring
shimeath_rafael
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Spring——单例Bean中使用多例Bean
通常bean都是单例的,如果一个bean需要依赖另一个bean时,被依赖的bean始终为单例的 让自定义bean获得applicationContext的能力 org.springframework.context.ApplicationContextAware public interface ApplicationContextAware extends Aware { void se...原创 2020-04-13 22:36:36 · 554 阅读 · 0 评论 -
DI——手动注入
构造器注入 三种依赖注入方式 格式 1. 通过index注入,为index设置需要注入参数的位置(**从0开始**) 2. 通过type注入,以类型注入 3. 通过方法参数名注入,参数名可能会有不稳定情况 <bean id="" class=""> <!-- <constructor-arg index="" value=""/> or <construc...原创 2020-04-07 18:11:26 · 127 阅读 · 0 评论 -
bean scope——bean的作用域及注意点
singleton 注意事项: 默认为singleton,即为单例。 整个应用共享,需考虑线程安全。 配置方式: <bean id="" class="" scope="singleton" >或<bean id="" class="" > prototype 注意事项: 需要在scope属性中指定prototype,多例。 每次获取时需重新加载。若实例较大,...原创 2020-04-06 10:23:24 · 166 阅读 · 0 评论