异常-----spring明明注入了Service到Action中,为什么运行的时候Service为空,在抽象类中,有子类来继承的
xml的配置文件
<bean id="fftController" class="com.bill99.query.controller.FftController" abstract="true">
<property name="wxOrderService" ref="wxOrderService" />
</bean>
<bean id="wxFFanController1" class="com.bill99.query.controller.WXFFanController1" parent="fftController">
<property name="methodNameResolver">
<ref bean="paramResolver" />
</property>
<property name="wxOrderService"
ref="wxOrderService" >
</property> /就是他们引起了。
<property name="fileProcessManage">
<ref bean="fileProcessManage" />
</property>
</bean>
2,
public abstract class FftController extends BaseController {
protected WxOrderService wxOrderService;
public void save(HttpServletRequest request, HttpServletResponse response) {
logger.info("save info begin...");
Map<String, Object> result = new HashMap<String, Object>();
try {
String wxOpenId = request.getParameter("wxOpenId");
String applyId = request.getParameter("applyId");
String wxModuleType = request.getParameter("wxModuleType");
//UploadFile1(request,response,applyId);
if (StringUtil.isEmpty(wxOpenId) || StringUtil.isEmpty(applyId)
|| StringUtil.isEmpty(wxModuleType)) {
result.put("code", "001");
result.put("desc", "必填参数为空");
super.toJson(result, response);
return;
}
// 获取request里的所有参数,作为orderParam
String paramJson = packageOrderParam(request);
// 查询对象
WxOrder wxOrder = new WxOrder();
wxOrder.setWxOpenId("666");
wxOrder.setApplyId(applyId);
wxOrder.setWxModuleType("777");
// 查询是否已经存在 wxOrderService就是在这空了的
WxOrder query = wxOrderService.findWxOrderByModel(wxOrder);
if (null != query) {
wxOrder = query;
wxOrder.setOrderParam(paramJson);
wxOrder.setLastupDate(new Date());
wxOrderService.updateWxOrder(wxOrder);
} else {
wxOrder.setOrderParam(paramJson);
wxOrder.setCreateDate(new Date());
wxOrder.setLastupDate(new Date());
wxOrderService.createWxOrder(wxOrder);
}
result.put("code", "000");
result.put("desc", "success");
super.toJson(result, response);
return;
} catch (Exception e) {
logger.error("", e);
result.put("code", "099");
result.put("desc", "系统异常");
super.toJson(result, response);
return;
}
}
3.
public class WXFFanController1 extends FftController {
protected WxOrderService wxOrderService;/就是他们引起的。
public void setWxOrderService(WxOrderService wxOrderService) {
this.wxOrderService = wxOrderService;
}
产生,为空的原因主要是因为父类中已经注入了,而在子类中又注入了一遍,产生空了。解决方案就是把子类的删除掉,子类可以直接用wxOrderService。不需要重新注入的。
<bean id="wxFFanController1" class="com.bill99.query.controller.WXFFanController1" parent="fftController">
<property name="methodNameResolver">
<ref bean="paramResolver" />
</property>
<property name="fileProcessManage">
<ref bean="fileProcessManage" />
</property>
</bean>
public class WXFFanController1 extends FftController {
}
异常-----spring明明注入了Service到Action中,为什么运行的时候Service为空,在抽象类中,有子类来继承的的更多相关文章
- Spring(二十三):Spring自动注入的实现方式
注解注入顾名思义就是通过注解来实现注入,Spring和注入相关的常见注解包含:Autowrired/Resource/Qualifier/Service/Controller/Repository/C ...
- Spring中抽象类中使用EmbeddedValueResolverAware和@PostConstruct获取配置文件中的参数值
我的需求: 我有一个 abstract class 中包含了很多子类中需要用到的公共方法和变量,我想在抽象类中 使用@Value获取*.properties中的值.但是@Value必须要在Spring ...
- spring的注入
1 可能遇到的问题: 异常信息 NoSuchBeanDefinitionException: No matching bean of type [...]或是NoSuchBeanDefinitionE ...
- Spring的注入问题
作下笔记,Spring的注入问题[多个实例问题] 解决方案如下: package student.life.support.platform.service.impl; import javax.an ...
- Spring依赖注入 --- 简单使用说明
Spring依赖注入 --- 简单使用说明 本文将对spring依赖注入的使用做简单的说明,enjoy your time! 1.使用Spring提供的依赖注入 对spring依赖注入的实现方法感兴趣 ...
- 为什么多线程、junit 中无法使用spring 依赖注入?
为什么多线程.junit 中无法使用spring 依赖注入? 这个问题,其实体现了,我们对spring已依赖太深,以至于不想自己写实例了. 那么到底是为什么在多线程和junit单元测试中不能使用依赖注 ...
- spring整合mybatis错误:Could not autowire field: com.kjczwl.ssm.service.ItemsService com.kjczwl.ssm.controller.ItemsController.itemsservice;
运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse 错误:Could not autowire field: com.kj ...
- Spring ——依赖注入配置一些知识点
依赖注入 依赖注入的原理与实现 依赖注入(DI)和依赖查找(Dependency Lookup)共同组成 控制反转(IoC).从原理的角度来说,依赖注入和控制反转是没 有不同的,可以看作是从两个角度来 ...
- Spring IOC 注入方式详解 附代码
引言 Spring框架作为优秀的开源框架之一,深受各大Java开发者的追捧,相信对于大家来说并不陌生,Spring之所以这么流行,少不了他的两大核心技术IOC和IOP.我们这里重点讲述Spring框架 ...
随机推荐
- bzoj 1930: [Shoi2003]pacman 吃豆豆 [费用流]
1930: [Shoi2003]pacman 吃豆豆 题意:两个PACMAN吃豆豆.一开始的时候,PACMAN都在坐标原点的左下方,豆豆都在右上方.PACMAN走到豆豆处就会吃掉它.PACMAN行走的 ...
- BZOJ 3309: DZY Loves Math [莫比乌斯反演 线性筛]
题意:\(f(n)\)为n的质因子分解中的最大幂指数,求\(\sum_{i=1}^n \sum_{j=1}^m f(gcd(i,j))\) 套路推♂倒 \[ \sum_{D=1}^n \sum_{d| ...
- SDN第一次上机作业
作业链接 用字符命令生成拓扑,并测试连通性,截图 sudo mn --topo tree,fanout=3,depth=2 用可视化界面生成拓扑,并测试连通性,截图 用Python脚本生成一个Fat- ...
- python重新利用shodan API
前言: 之前写过一个shodan的API调用 感觉写的不这么好.然后现在重新写一个 shodan介绍: shodan是互联网上最可怕的搜索引擎. CNNMoney的一篇文章写道,虽然目前人们都认为谷歌 ...
- Angular Pipe的应用
1-在html文件中使用管道:(管道符合使用,用':'号隔开) ①页面中添加: <div class="table_content" *ngFor="let ite ...
- Centos 7系统优化脚本
脚本如下,后续继续优化 #!/bin/bash #author junxi by #this script is only for CentOS 7.x #check the OS platform= ...
- WinForm中使用DDE技术(含源码)
提起DDE技术,相信很多人不知道是啥东东,尤其是90后的程序员们.不过,有时候这个东西还是有用处的,用一句话可以总结:实现Winform程序间的通信.比如:两个Winform程序A和B需要实现通信,用 ...
- jquery序列化serialize()方法空格变为+问题解决参考方法
$("#sendNoticeData-form").serialize();会在value中存在空格的地方转化为+符合.比如:name:tiwax aaa序列化后为tiwax+aa ...
- 通过js区分移动端浏览器(微信浏览器、QQ浏览器、QQ内置浏览器)
由于公司业务中涉及到一个分享指引功能,而像微信.QQ内置浏览器需要引导用户点击右上角进行操作,其他浏览器则引导点击浏览器下方进行操作,因此需要区分浏览器类型: 通过在页面alert(navigator ...
- Yii的HTML助手
Html 帮助类 基础 表单 样式表和脚本 超链接 图片 列表 任何一个 web 应用程序会生成很多 HTMl 超文本标记.如果超文本标记是静态的, 那么将 PHP 和 HTML 混合在一个文件里 这 ...