@Autowired DAO

时间:2015-10-12 20:30:20

标签: java spring jdbctemplate

这是我的抽象类

public abstract class ReqTaskGenerator implements ITaskGenerator {

    @Autowired
    private SlaDAO slaDAO;

    protected Integer getDuration() {
        Integer dur = 0;
        if (ValidationUtil.isValidNonZeroNumber(duration)) {
            dur = duration;
        } else {
            String status = REQTAG
                    + ReqStates.getEnumFromCode(req.getStatus())
                            .getInternalName();
            System.out.println(status);
            System.out.println(slaDAO);
            Sla sla = slaDAO.getSlaForAState(status);
            if (sla != null) {
                dur = sla.getSlaDuration();
            }
        }
        return dur;
    }


}

此摘要由以下类扩展

public class NewReqTaskGenerator extends ReqTaskGenerator {

    public NewReqTaskGenerator(Requirement req, Integer duration) {
        super(req, duration);
    }

    @Override
    public Task generateTask() {
        Task reqTask = populateDefaultTaskData();
        reqTask.setName("New Requirement waiting for submission");
        reqTask.setSlaDuration(0);
        reqTask.setAssignees(getTaskAssignes());
        saveTask(reqTask);
        return reqTask;
    }
}
来自子类的

我正在调用父抽象类中定义的函数,该抽象类具有自动装配的SlaDAO,这会抛出零点异常。

这是dao的弹簧上下文bean定义条目

<beans:bean id="slaDAO"
        class="com.project.dao.SlaDAO">
        <beans:property name="dataSource" ref="dataSource" />
    </beans:bean>

有人能告诉我为什么slaDao为空

0 个答案:

没有答案