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为空,在抽象类中,有子类来继承的的更多相关文章

  1. Spring(二十三):Spring自动注入的实现方式

    注解注入顾名思义就是通过注解来实现注入,Spring和注入相关的常见注解包含:Autowrired/Resource/Qualifier/Service/Controller/Repository/C ...

  2. Spring中抽象类中使用EmbeddedValueResolverAware和@PostConstruct获取配置文件中的参数值

    我的需求: 我有一个 abstract class 中包含了很多子类中需要用到的公共方法和变量,我想在抽象类中 使用@Value获取*.properties中的值.但是@Value必须要在Spring ...

  3. spring的注入

    1 可能遇到的问题: 异常信息 NoSuchBeanDefinitionException: No matching bean of type [...]或是NoSuchBeanDefinitionE ...

  4. Spring的注入问题

    作下笔记,Spring的注入问题[多个实例问题] 解决方案如下: package student.life.support.platform.service.impl; import javax.an ...

  5. Spring依赖注入 --- 简单使用说明

    Spring依赖注入 --- 简单使用说明 本文将对spring依赖注入的使用做简单的说明,enjoy your time! 1.使用Spring提供的依赖注入 对spring依赖注入的实现方法感兴趣 ...

  6. 为什么多线程、junit 中无法使用spring 依赖注入?

    为什么多线程.junit 中无法使用spring 依赖注入? 这个问题,其实体现了,我们对spring已依赖太深,以至于不想自己写实例了. 那么到底是为什么在多线程和junit单元测试中不能使用依赖注 ...

  7. 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 ...

  8. Spring ——依赖注入配置一些知识点

    依赖注入 依赖注入的原理与实现 依赖注入(DI)和依赖查找(Dependency Lookup)共同组成 控制反转(IoC).从原理的角度来说,依赖注入和控制反转是没 有不同的,可以看作是从两个角度来 ...

  9. Spring IOC 注入方式详解 附代码

    引言 Spring框架作为优秀的开源框架之一,深受各大Java开发者的追捧,相信对于大家来说并不陌生,Spring之所以这么流行,少不了他的两大核心技术IOC和IOP.我们这里重点讲述Spring框架 ...

随机推荐

  1. BZOJ 1226: [SDOI2009]学校食堂Dining [DP 状压]

    题意: $n$个人排队打饭,第$i$个人口味$a_i$,能容忍最多身后第$b_i$个人先打饭. 先后两人$i,j$做饭时间为$a_i & a_j - a_i | a_j$ 求最少时间 一开始想 ...

  2. BZOJ 3450: Tyvj1952 Easy [DP 概率]

    传送门 题意:$ox?$组成的序列,$?$等概率为$o\ or\ x$,得分为连续的$o$的长度的平方和,求期望得分 一开始没想出来,原因在于不知道如何记录长度 其实我们同时求得分和长度的期望就好了 ...

  3. 数据提交成功后如何避免alert被window.location.reload()影响

    数据提交成功用alert提示,但页面立马就重载了 alert("提交成功!"); window.location.reload(); 如何避免? 方法一: setTimeout 延 ...

  4. php 数组变成树状型结构

    <? php $stime = microtime(true); $nodes = [ ['id' = > 1, 'pid' = > 0, 'name' = > 'a'], [ ...

  5. 调试 smallcorgi/Faster-RCNN_TF 的demo过程遇到的问题

    最近在调试faster R-CNN时,遇到了各种各样的问题.使用的算法库为https://github.com/smallcorgi/Faster-RCNN_TF 注:本文使用的是通过virtuale ...

  6. 一个脚本从git上pull 并更新到服务器

    #/bin/bash cd /src/pid01-beta/ echo "update pid01.." git pull ]; then echo "update pi ...

  7. iOS 应用开发,用户密码存储技术--KeyChain

    文/清雪飘香(简书作者)原文链接:http://www.jianshu.com/p/c41525172aee著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 这次的Xcode 事件,让我 ...

  8. html拨打电话、发送短信、发送邮件的链接写法

    拨打电话 <a href="tel:88888888">呼叫</a> 发送短信 <a href="sms:88888888"> ...

  9. Ehcache入门基础

    1.ehcache的简介  EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点,是Hibernate中默认的CacheProvider. 2.ehcache入门实例 1.首先先导入 ...

  10. properties基本用法

    package control; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io. ...