引入 ServletContextListener @Autowired null 解决办法
public class ScheduleController implements ServletContextListener {
@Autowired
private ScheduleService scheduleService; @Override
public void contextDestroyed(ServletContextEvent event) {
System.out.println("销毁");
} @Override
public void contextInitialized(ServletContextEvent event) {
WebApplicationContextUtils.getRequiredWebApplicationContext(event.getServletContext())
.getAutowireCapableBeanFactory().autowireBean(this);
System.out.println("开始执行周期任务");
scheduleService.start(); ;
}
}
如果使用ServletContextListener对spring启动前和停止前做一些清理工作的时时候,需要用到一些autowired的类,测试发现这些类在启动的时候,由于相应的beanfactory还没有加载,所以会出现问题。
引入 ServletContextListener @Autowired null 解决办法的更多相关文章
- Uncaught TypeError: Cannot set property 'onclick' of null解决办法
如果把js内容直接放在这个head标签以内,button按钮不能正常点击更换body的背景颜色,报错提示:demo6.html:16 Uncaught TypeError: Cannot set pr ...
- Android界面隐藏软键盘的探索(兼findViewById返回null解决办法)
最近写的APP,老师说我的登陆界面虽然有ScrollView滑动,但用户体验不太好,因为软键盘会挡住输入框或登录button(小米Pad,横屏,当指定只能输入数字时没找到关闭系统自带键盘的下箭头). ...
- SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 解决办法
当跑jndi项目时抛出:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' fo ...
- Hbase出现ERROR: Can't get master address from ZooKeeper; znode data == null解决办法
问题描述如下: hbase(main)::> list TABLE ERROR: Can't get master address from ZooKeeper; znode data == n ...
- Spring_关于@Resource注入为null解决办法
初学spring,我在dao层初始化c3p0的时候,使用@Resource注解新建对象是发现注入为null,告诉我 java.lang.NullPointerException. @Repositor ...
- ieda引入jstl后报错解决办法
报错如下: HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in ei ...
- Idea中重建maven模块,dependencies引入为空的解决办法
使用idea开发Maven项目时, Maven项目中有些模块被删除了,重新加入相同名字的模块时,dependencies为空 如下图 正常引进的项目,dependencies应如下 解决办法: ide ...
- PHP 获取JSON json_decode返回NULL解决办法
在用json_decode对JSON格式的字符串进行解码时竟然为空,页面空白啊,整半天检查这里检查那里,问同事都没用. 今天必应搜索了下,问题解决了,原来是有BOM头输出,大虾的解决办法如下: 1). ...
- Java 各级注解及@Autowired注入为null解决办法
1.@controller 控制器 用于标注控制层,相当于struts中的action层. 2.@service 服务层 用于标注服务层,主要用来进行业务的逻辑处理. 3.@repository DA ...
随机推荐
- Shell 编程 正则表达式
本篇主要写一些shell脚本正则表达式的使用基础. 概述 正则表达式分为基础正则表达式(Regular Expression)与扩展正则表达式(Extended Regular Expression) ...
- Redis开启远程访问及密码
一.开启远程访问 1.开放端口 firewall-cmd --zone=public --add-port=6379 firewall-cmd --zone=public --add-port=637 ...
- yum lockfile is held by another process
使用yum安装软件报错 yum lockfile is held by another process 解决方法 rm -f /var/run/yum.pid
- Two-Stream Adaptive Graph Convolutional Network for Skeleton-Based Action Recognition
Two-Stream Adaptive Graph Convolutional Network for Skeleton-Based Action Recognition 摘要 基于骨架的动作识别因为 ...
- WTL 9.0的变化 - atlapp.h
忽然发现WTL更新到9.0.4140了,便对比了一下 8.1.12085. 先看看atlapp.h中有什么大的变动. 第61行: #if defined(_SYSINFOAPI_H_) &&a ...
- 第09节-使用BTStack编写蓝牙程序
Bluetooth LE Exploer(微软提供的)可以读取BLE蓝牙设备,可以读写它的值.本篇博客将使用BTStack写出一个精简版的Bluetooth LE Exploer. 涉及文件: bts ...
- 4、组件注册-自定义TypeFilter指定过滤规则
4.组件注册-自定义TypeFilter指定过滤规则 4.1 FilterType.ANNOTATION 按照注解方式 4.2 FilterType.ASSIGNABLE_TYPE 按照给定的类型 @ ...
- haproxy 配置文件详解 之 backend
配置示例: backend htmpool mode http option redispatch option abortonclose balance static-rr cookie SESSI ...
- 出现:Microsoft Visual C++ 14.0 is required 的解决方案
以安装pandas为例: 如:pip install scrapy 时出现: error: Microsoft Visual C++ 14.0 is required. Get it with “Mi ...
- 作业:SSH
作业:使用SSH通过网络远程控制电脑 在虚拟机中用apt命令安装了ssh,但多次连接都失败了,尝试了很多次.后来发现只要是虚拟机中的系统使用的ip都是一样的从而发现了问题.虚拟机的网络是被更改后的,后 ...