spring相关记录

1.将xxx.properties文件转换成Properties对象,用到下面两个方法。

org.springframework.core.io.FileSystemResource.FileSystemResource(String)

org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(Resource)

具体实现为:

Resource resource = new FileSystemResource("...");

Properties = PropertiesLoaderUtils.loadProperties(resource);

2.现在org.springframework.beans.factory.FactoryBean<T>接口的类,在获取bean时调用的是实现类的getObject()方法;

3.获取注解的对象:

org.springframework.beans.factory.ListableBeanFactory.getBeansWithAnnotation(Class<? extends Annotation>)

4.初始化bean和销毁bean之前要想执行特定的动作有如下三种方式:

   第一种:通过@PostConstruct和@PreDestroy注解

   第二种:通过在xml中bean上定义init-method和destory-method属性

   第三种:通过实现InitializingBean和DisposableBean接口。

5.获取spring应用上下文的方法是实现ApplicationContextAware接口,重写setApplicationContext()方法

 

6.在spring容器启动时不能使用

WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();                        wac.getBean(beanID);  

转载于:https://my.oschina.net/u/2937247/blog/835342

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值