ContextLoader获取bean实例
来源:互联网 发布:自考师范本科 知乎 编辑:程序博客网 时间:2024/06/05 13:29
如下代码:获取DeviceService实例
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext(); DeviceService service = (DeviceService) context.getBean("deviceServiceImpl");
/** * 刷新设备信息 * @param device */public static Device refreshDevice(String wecDeviceId) { Jedis redis = MyJedisPool.getJedisObject();// 获得jedis实例 <font color=red> WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext(); DeviceService service = (DeviceService) context.getBean("deviceServiceImpl"); </font> Device device = service.getDeviceByWecDeviceId(wecDeviceId); if (device != null) { JSONObject jsonDevice = JSONObject.fromObject(device); String strDevice = String.valueOf(jsonDevice); redis.set(device.getWecDeviceId(), strDevice); redis.expire(device.getWecDeviceId(), EXPIRE_DAY); // 设置过期时间 } return device; }
阅读全文
0 0
- ContextLoader获取bean实例
- spring获取bean 实例
- Spring获取bean实例
- 获取配置文件中的Bean实例
- 自定义SpringContextHolder获取bean实例
- 通过BeanFactory获取Bean实例
- 使用SpringContextHolder获取bean实例
- Spring之Bean容器初始化以及bean实例的获取
- Spring框架中获取Bean实例
- 自定义SpringContextHolder获取bean实例(一)
- spring 从bean实例中获取对象
- spring boot获取注入的实例bean
- 获取SpringMVC上下文bean实例-SpringContextUtil
- spring-项目启动下获取Bean实例
- Spring中的Bean获取与实例化
- 获取spring bean 容器中实例,非创建新实例
- 获取Spring加载的实例bean/获取注解Beam
- AM使用指南:如何在Managed Bean中获取AM实例?
- 手机REM使用代码
- AOP 面向切面编程
- Java中带有T Z格式(UTC是世界标准时间)的时间转换为date,string,long类型
- 新的开始
- 命令模式(Command)-----基于JAVA语言
- ContextLoader获取bean实例
- 程序人生
- 在VS2015中用C++创建DLL并用C#调用且同时实现对DLL的调试
- Android侧滑-DrawerLayout
- 线程池的使用
- 模拟实现memcpy,memmove,memset
- Linux 安装Nginx详细图解教程
- 苹果开发者账号中,测试机器列表已达到100台上限,怎么办
- Android Studio生成apk安装返回失败ErrorCode:-15、INSTALL_FAILED_TEST_ONLY