对于初始化函数:

  1. @PostConstruct 注解的方法
  2. InitializingBean接口定义的回调afterPropertiesSet()
  3. Bean配置中自定义的初始化函数

对于析构则与上相同:

  1. @PreDestroy注解的方法
  2. DisposableBean接口定义的回调destroy()
  3. Bean配置中自定义析构函数
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
default-init-method="init"
default-destroy-method="close"
> <bean id="user0" class="com.test.service.UserServiceIml" init-method="testInit" destroy-method="testBeforeDesstroy">

https://blog.csdn.net/windsunmoon/article/details/44276765

spring InitializingBean和DisposableBean init-method 和destroy-method @PostConstruct @PreDestroy的更多相关文章

  1. Spring InitializingBean and DisposableBean example

    In Spring, InitializingBean and DisposableBean are two marker interfaces, a useful way for Spring to ...

  2. java代码中init method和destroy method的三种使用方式

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  3. spring init method destroy method

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  4. Spring中Bean的生命中期与InitializingBean和DisposableBean接口

    Spring提供了一些标志接口,用来改变BeanFactory中的bean的行为.它们包括InitializingBean和DisposableBean.实现这些接口将会导致BeanFactory调用 ...

  5. Spring Bean InitializingBean和DisposableBean实例

    在Spring中,InitializingBean和DisposableBean是两个标记接口,为Spring执行时bean的初始化和销毁某些行为时的有用方法. 对于Bean实现 Initializi ...

  6. Spring Bean Life Cycle Methods – InitializingBean, DisposableBean, @PostConstruct, @PreDestroy and *Aware interfaces

    Spring Beans are the most important part of any Spring application. Spring ApplicationContext is res ...

  7. Spring bean 实现InitializingBean和DisposableBean接口实现初始化和销毁前操作

    # InitializingBean接口> Spring Bean 实现这个接口,重写afterPropertiesSet方法,这样spring初始化完这个实体类后会调用这个方法```@Over ...

  8. 【Spring注解驱动开发】使用InitializingBean和DisposableBean来管理bean的生命周期,你真的了解吗?

    写在前面 在<[Spring注解驱动开发]如何使用@Bean注解指定初始化和销毁的方法?看这一篇就够了!!>一文中,我们讲述了如何使用@Bean注解来指定bean初始化和销毁的方法.具体的 ...

  9. InitializingBean和DisposableBean

    InitializingBean 记住一点:InitializingBean接口为bean提供了初始化方法的方式,它只包括afterPropertiesSet方法,凡是继承该接口的子类,在初始化bea ...

随机推荐

  1. python day03笔记总结

    2019.3.29 S21 day03笔记总结 昨日回顾及补充 1.运算符补充 in not in 2.优先级 运算符与运算符之间也有优先级之分 今日内容 一.整型(int) py2 与 py3 的区 ...

  2. springBoot 全局异常方式处理自定义异常 @RestControllerAdvice + @ExceptionHandler

    前言 本文讲解使用 @ControllerAdvice + @ExceptionHandler 进行全局的 Controller 层异常处理,可以处理大部分开发中用到的自自定义业务异常处理了,再也不用 ...

  3. step_by_step_记录deepin下curl安装过程

    记录 deepin 下 curl 安装过程 wget https://curl.haxx.se/download/curl-7.55.1.tar.gz .tar.gz cd curl-/ ./conf ...

  4. css: box-sizing

    border-box 宽度包含了边框 content-box 边框不包含在内容区中,会增加到实际的宽度中

  5. JavaScript图片上传前的图片预览功能

    JS代码: //js本地图片预览,兼容ie[6-9].火狐.Chrome17+.Opera11+.Maxthon3 function PreviewImage(fileObj, imgPreviewI ...

  6. Dockerfile的常见命令

    FROM 格式: FROM  <image> 或者  FROM <image>:<tag> FROM指令的功能是为后面的指令提供基础镜像,所以该指令一定是Docke ...

  7. Checkbox的只读设置

    readonly和disabled属性均不生效.可按如下方式处理,记得引入jquery.js文件 <input type="checkbox" name="chk& ...

  8. SQLServer导入导出命令报错

    错误描述: SQL Server阻止了对组件‘xp_cmdshell’的过程‘sys.xp_cmdshell’的访问.因为此组件已作为此服务嚣安全配置的一部分而被关闭. 系统管理员可以通过使用sp_c ...

  9. synchronized锁机制 之 代码块锁(转)

    synchronized同步代码块 用关键字synchronized声明方法在某些情况下是有弊端的,比如A线程调用同步方法执行一个较长时间的任务,那么B线程必须等待比较长的时间.这种情况下可以尝试使用 ...

  10. 使用idea的springboot项目出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    参考: https://www.cnblogs.com/lfm601508022/p/InvalidBoundStatement.html https://blog.csdn.net/xsggsx/a ...