1、实现ApplicationListener接口,并重写onApplicationEvent方法

@Component
public class RSAKeyInitListener implements ApplicationListener<ContextRefreshedEvent> { @Autowired
BaseAppConfigDao baseAppConfigDao; @Override
public void onApplicationEvent(ContextRefreshedEvent event) {
//具体操作
}
}

2、创建spring的应用上下文(ApplicationContext.xml),并配置注解扫描

<context:component-scan base-package="com.xxx.xxx.facex.listener" />

3、配置web.xml

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 也可以与context-param标签一起使用 -->
   <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

spring中ApplicationListener的用法的更多相关文章

  1. 框架源码系列十:Spring AOP(AOP的核心概念回顾、Spring中AOP的用法、Spring AOP 源码学习)

    一.AOP的核心概念回顾 https://docs.spring.io/spring/docs/5.1.3.RELEASE/spring-framework-reference/core.html#a ...

  2. Spring中ApplicationListener的使用

    背景 ApplicationListener是Spring事件机制的一部分,与抽象类ApplicationEvent类配合来完成ApplicationContext的事件机制. 如果容器中存在Appl ...

  3. Spring中@Cacheable的用法

    在Spring中通过获取MemCachedClient来实现与memcached服务器进行数据读取的方式.不过,在实际开发中,我们往往是通过Spring的@Cacheable来实现数据的缓存的,所以, ...

  4. Spring中HibernateCallback的用法(转)

    Hibernate的复杂用法HibernateCallback HibernateTemplate还提供一种更加灵活的方式来操作数据库,通过这种方式可以完全使用Hibernate的操作方式.Hiber ...

  5. Spring中jdbcTemplate的用法实例

    一.首先配置JdbcTemplate: 要使用Jdbctemplate 对象来完成jdbc 操作.通常情况下,有三种种方式得到JdbcTemplate 对象.       第一种方式:我们可以在自己定 ...

  6. Spring 中classPath:用法

    参考文章地址: http://hi.baidu.com/huahua035/item/ac8a27a994b55bad29ce9d39 http://blog.csdn.net/lushuaiyin/ ...

  7. spring 中StoredProcedure的用法--转载

    StoredProcedure是一个抽象类,必须写一个子类来继承它,这个类是用来简化JDBCTemplate执行存储过程操作的. 首先我们写一个实现类: package com.huaye.frame ...

  8. Spring中ApplicationContextAware的用法

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt379 一.这个接口有什么用? 当一个类实现了这个接口(Application ...

  9. Spring中RedirectAttributes的用法

    RedirectAttributes 是Spring mvc 3.1版本之后出来的一个功能,专门用于重定向之后还能带参数跳转的的工具类.他有两种带参的方式: 第一种: redirectAttribut ...

随机推荐

  1. SVN导出差异版本更新的文件列表

    对于在服务器上没有使用版本控制的运维人员来说,每次SVN修改的文件都需要查看更改日志,一个个查找出来再更新到服务器,过程实在是痛苦 那么有没有一种方法跑个命令比对一下版本就哗啦啦的把修改好的文件复制出 ...

  2. day22

    # day22 ## 复习 ```python# 1.内存管理# 引用计数:垃圾回收机制工作原理# -- 引用就 +1 ,释放就 -1 , 当计数为0时,就会被垃圾回收机制回收 # 标记清除:解决循环 ...

  3. Axure文本框验证和外部url的调用

    文本框的验证和外部url的调用: 场景: 当输入文本框中的内容是满足下面条件时:输入4-10的数字,页面会跳转到QQ注册(https://ssl.zc.qq.com/v3/index-chs.html ...

  4. 在Mac os 10.11 下编译Berkeley caffe

    安装各种补丁和组件,缺啥装啥. python 采用 2.7.13 最新版. 安装工具  homebrew , pip 很繁琐,但是没难度. 由于本人macbook pro不支持CUDA,所以不用安装. ...

  5. elementUi中input输入字符光标在输入一个字符后,光标失去焦点

    elementUi中input输入字符光标在输入一个字符后,光标就退出,无法输入需要再次聚焦然后输入一个字符又再次退出 首先,用elementUi正常用v-model绑定输入的值是不会造成光标退出的, ...

  6. 使用 jquery.wordexport.js导出的Word排版

    js导出word文档所需要的两个插件: FileSaver.js jquery.wordexport.js 使用jquery.wordexport.js这个插件导出的word文档的排版方式: 编辑器打 ...

  7. Postman中x-www-form-urlencoded请求K-V的ajax实现

    在Postman中使用x-www-form-urlencoded,并且用K-V传值,但是在代码中用ajax来请求,传值一直有问题,静下心来思考才发现K-V传入的是string,所以记录下来以防忘记!! ...

  8. Django中ORM介绍和字段及字段参数

    Object Relational Mapping(ORM) 1 ORM介绍 1.1 ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对 ...

  9. Petrozavodsk Winter Camp, Warsaw U, 2014, A The Carpet

    一个地图上有若干障碍,问允许出现一个障碍的最大子矩形为多大? 最大子矩形改编 #include<bits/stdc++.h> using namespace std; #define re ...

  10. Vue 知识整理—02-起步

    一:Vue 语法格式: vue vm = new Vue({ //选项 }) 二:Vue 实例: <div id="app"> <p>{{message}} ...