Spring 的 init-method 和 destory-method
关于在spring 容器初始化 bean 和销毁前所做的操作定义方式有三种
第一种注解:
通过@PostConstruct 和 @PreDestroy 方法 实现初始化和销毁bean之前进行的操作
第二种是XML配置:
通过 在xml中定义init-method 和 destory-method方法
第三种是接口实现:
通过bean实现InitializingBean和 DisposableBean接口
具体接口和方法如表
Spring Bean 生命周期各阶段 |
相关接口及方法 |
Bean 自身方法 |
Bean 本身业务的方法: 配置文件中 init-method 和 destroy-method 指定的方法 |
Bean 生命周期接口方法 |
Initial izingBean 接口 DiposableBean 接口 BeanNameAware 接口 ApplicationCantextAware 接口 BeanFac町Aware 接口 其他 |
容器级生命周期接口方法 (一般称为“后处理器”) |
lnstantiationAwareBeanPostPracessor 接口实现 BeanPostProcessor 接口实现 |
工厂级生命周期接口方法 (也可以归为容器级的) |
AspecUWeavingEnabler Con丑gurationC!assPostProcessor CustomAutowireConfigurer 等 |
生命周期 时序图
Spring 的 init-method 和 destory-method的更多相关文章
- java代码中init method和destroy method的三种使用方式
在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...
- Modified Least Square Method and Ransan Method to Fit Circle from Data
In OpenCv, it only provide the function fitEllipse to fit Ellipse, but doesn't provide function to f ...
- 关于.ToList(): LINQ to Entities does not recognize the method ‘xxx’ method, and this method cannot be translated into a store expression.
LINQ to Entities works by translating LINQ queries to SQL queries, then executing the resulting quer ...
- Invalid character found in method name. HTTP method names must be tokens
o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header Note: further occurrenc ...
- SpringBoot:Invalid character found in method name. HTTP method names must be tokens
问题背景 关于SpringBoot应用挂了很久之后,会发生Invalid character found in method name. HTTP method names must be token ...
- Day04 -玩弄Ruby的方法:instance method与class method
前情提要在第三天时,我们解说了如何在class里用include与extend,去使用module的method. Include is for adding methods to an instan ...
- tomcat 启动报错 Invalid character found in method name. HTTP method names must be tokens
解决:Invalid character found in method name. HTTP method names must be tokens 阿里云上弄了一个tomcat,经常半夜发送崩 ...
- [Python] Python 之 function, unbound method 和 bound method
首先看一下以下示例.(Python 2.7) #!/usr/bin/env python # -*- coding: utf-8 -*- class C(object): def foo(self): ...
- Python OOP(2)-static method,class method and instance method
静态方法(Static Method): 一种简单函数,符合以下要求: 1.嵌套在类中. 2.没有self参数. 特点: 1.类调用.实例调用,静态方法都不会接受自动的self参数. 2.会记录所有实 ...
- Postman请求后台报错:Invalid character found in method name. HTTP method names must be tokens
在使用Postman请求后台时Postman出现 开发工具控制台报 信息: Error parsing HTTP request header Note: further occurrences of ...
随机推荐
- Navicat for MySQL 批量执行多个 SQL 文件
文件合并 type *.sql >> aaa.sql 执行sql文件 右键点击数据库
- Linux 下权限的管理
Linux 下权限的管理 我们都知道,Linux系统对于用户的权限管理是十分严格的. 那么,我们就来具体了解一下. 一. 用户 在Linux中按照类型用户分为两种:1.超级用户 2.普通用户 那么它们 ...
- Flink sql 之AsyncIO与LookupJoin的几个疑问 (源码分析)
本文源码基于flink 1.14 被同事问到几个关于AsyncIO和lookUp维表的问题所以翻了下源码,从源码的角度解惑这几个问题 对于AsyncIO不了解的可以看看之前写的这篇 <Flin ...
- nose在python2与python3中的包的自动发现用例的区别
最近在使用python3,同样装了nose,发现自动发现用例总是有问题,如下面的代码结婚 testcase |------ __init__.py |------ test_bb.py test_bb ...
- MyBatis Plus中使用and和or
如图:show me the code 参考: https://mp.baomidou.com/guide/wrapper.html#or
- nio实现文件夹内容的监听
参考的博客 package com.jp.filemonitor; import java.io.IOException; import java.nio.file.FileSystems; impo ...
- Flask WTForm disable choice field
Flask disable choice field ChoiceField = { render_kw={'disabled':''} } form.my_field.render_kw = {'d ...
- SQL 添加列,删除列,修改列的类型
alter table 表名 add 列名 数据类型 如:alter table student add nickname char(20) alter table tableName(表名) add ...
- Nginx的try_files指令使用实例
Nginx的配置语法灵活,可控制度非常高.在0.7以后的版本中加入了一个try_files指令,配合命名location,可以部分替代原本常用的rewrite配置方式,提高解析效率. try_file ...
- [atARC107F]Sum of Abs
价值即等价于给每一个点系数$p_{i}=\pm 1$,使得$\forall (x,y)\in E,p_{x}=p_{y}$的最大的$\sum_{i=1}^{n}p_{i}b_{i}$ 如果没有删除(当 ...