使用ServletContextListener无法直接注入sping配置文件中接口解决办法
来源:互联网 发布:42u图腾网络机柜尺寸 编辑:程序博客网 时间:2024/05/22 05:16
ServletContextListener服务启动时,在启动调用方法中直接读取spring ApplicationContext.xml配置文件,拿到接口,直接使用。
private static ApplicationContext context = null;public void initPlatformData() {if(context == null){ //读取ApplicationContext.xml配置文件 context = new ClassPathXmlApplicationContext("applicationContext.xml");} //拿到目标接口 IStatisticsService statisticsService = (IStatisticsService) context.getBean("statisticsService");try { 调用接口中的方法 statisticsService.initPlatformData();} catch (Exception e) {e.printStackTrace();}}
0 0
- 使用ServletContextListener无法直接注入sping配置文件中接口解决办法
- Sping使用 AOP时 无法依赖注入问题
- ServletContextListener接口使用
- 怎样使用ServletContextListener接口
- 怎样使用ServletContextListener接口
- ServletContextListener接口的使用心得
- ServletContextListener接口的使用心得
- ServletContextListener接口的使用心得
- ServletContextListener接口的使用心得
- ServletContextListener接口的使用心得
- 使用Spring开发中,service接口或者是dao层接口无法注入
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- tomcat中无法直接使用应用名来访问,必须使用具体页面名称的解决办法
- Sping用set方式注入单个对象配置文件
- ServletContextListener 接口
- ServletContextListener接口
- Sping中使用Hibernate浅析
- 最短路 - Dijkstra()
- wordpress建立自定义菜单
- Pilots(pilots)题解
- Runtime.getRuntime().exec(strMakePathPath);
- 【CCF】相反数
- 使用ServletContextListener无法直接注入sping配置文件中接口解决办法
- mysql报错:could not find settings Either the server service or the configuration file could not be fou
- PHP函数随机学习。
- 验证码短信接口如何使用
- iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务等等
- 【POJ1032】把一个数分解为不重复的数的和使其乘积最大
- ZooKeeper基本原理
- 黑马程序员-Java基础学习-反射技术
- 工具_SublimeText