日期:2014-05-17  浏览次数:20730 次

纠结一夜没睡,好困,spring mvc注入抽象方法的子类注册不成功
本人用spring mvc写了一个项目,现有一个抽象类,两个抽象类的子类,想在controller中注入一个抽象类的实现类,可是老是提示我的父类没有注册
直接上图了

配置文件
<!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd -->
<mvc:resources mapping="/img/**" location="/imgage/"/>
<mvc:resources mapping="/js/**" location="/js/"/>
<mvc:resources mapping="/css/**" location="/css/"/>
<mvc:resources mapping="/html/**" location="/html/"/>

<!-- 
①:对web包中的所有类进行扫描,以完成Bean创建和自动依赖注入的功能 
-->
<context:annotation-config/>
<context:component-scan base-package="com.honestspring.controller"></context:component-scan>
<context:component-scan base-package="com.honestspring.dao"></context:component-scan>
<context:component-scan base-package="com.honestspring.service"></context:component-scan>
<context:component-scan base-package="com.honestspring.sys.component"></context:component-scan>
<context:component-scan base-package="com.honestspring.sys.tld"></context:component-scan>
<context:component-scan base-package="com.honestspring.model"></context:component-scan>


调用的地方
	@Autowired
@Qualifier("hSListViewComponent")
public AbtractSysViewComponent hsViewComponent;

其中 AbstractSysViewComponent类
import com.honestspring.util.XMLManager;

public abstract class AbtractSysViewComponent {
public abstract String spellFileName(String module);

public Document getResource(String module) {

实现类
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import com.honestspring.common.Constant;
import com.honestspring.sys.model.DataGrid;
import com.honestspring.sys.screen.model.Column;
import com.honestspring.sys.screen.model.Function;
import com.honestspring.sys.screen.model.Toolbar;
import com.honestspring.util.DataGridModel;
import com.honestspring.util.XMLManager;

@Component
public class HSListViewComponent extends AbtractSysViewComponent {
@Autowired
private FieldWidthOfListStrategyIntf fieldWidthOfListStragey;


报错信息 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listViewAjaxController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public com.honestspring.sys.component.AbtractSysViewComponent com.honestspring.controller.ListViewAjaxController.hsViewComponent; nested exception is org.springframework.beans.factory.NoSuchBeanDefinit