#spring注入为空null,普通类中引用springIOC类
来源:互联网 发布:男士衣服搭配 知乎 编辑:程序博客网 时间:2024/06/10 06:05
spring注入为空null,普通类中引用springIOC类
Java普通类中代码
private DrduRepertory container; private ILocationService ilocationService;private void initdata(){//从springIoc取得需要的serviec类 container =(DrduRepertory)SpringTool.getBean("DrduRepertory"); ilocationService=(ILocationService)SpringTool.getBean("ILocationServiecImpl"); //把考场信息放到MAP里,考场kcdddh为key List<DrvExaminationSiteSchema> list2=container.getExamStie();}
配置XML
<bean class="com.slintec.common.util.SpringTool" /><bean id="DrduRepertory" class="com.slintec.location.service.DrduRepertory"/> <bean id="ILocationServiecImpl" class="com.slintec.location.service.impl.ILocationServiecImpl" />
别忘了引入jar包
取得转换就和@Autowired一样
注意:需要用接口,不是实体类
阅读全文
1 0
- #spring注入为空null,普通类中引用springIOC类
- 关于spring依赖注入到普通类中为null的情况解决理解方案
- 在普通类中使用Spring注入
- Spring 父类注入的属性 在子类中调用为null
- 在多线程类中,Spring注入对象为null问题处理
- spring 在普通类中调用注入的对象
- (亲测有效。)Spring MVC中,Controller中使用service只需使用注解,但是普通类获取 service或 dao 都是null空的。
- Spring bean注入为null
- spring注入静态bean步骤 spring在普通类中注入bean实例
- SpringBoot在自定义类中注入Service为null
- 普通类中引用spring 容器管理的bean
- 多线程中引入Spring自动注入的对象为null
- Spring @Autowired注解在非Controller中注入为null
- spring新线程中注入为空指针的问题
- spring如何对普通类进行注入
- Spring中Map的key为对象引用的注入
- spring流入静态bean spring在普通类中注入bean实例
- 普通类如何引用Spring的bean?
- protocol buffer 常用API
- system类
- 从零开始学习音视频编程技术(30) Linux篇之系统安装
- 获取某段时间内的小时、日期、月份,存储过程中使用的较多。
- 图像分割—基于图像数据的自动选择阈值(基本全局阈值处理方法)
- #spring注入为空null,普通类中引用springIOC类
- Navicat 导入数据报错 --- 1153
- 安装Ubuntu 出现 SQUASFS error / sd 8:0:0:0 :[sdb] assuming drive cache:write through
- JNI笔记 JNI引用,异常处理,初始化成员变量
- MySql避免重复插入记录方法(ignore,Replace,ON DUPLICATE KEY UPDATE)
- PHP求非重复字符串的最大值
- TensorFlow 介绍 tf.nn.softmax_cross_entropy_with_logits 的用法
- Struts框架中OGNL标签与EL标签表达式使用
- android 将简单的数据存储到本地-SharedPreferences