SSH中的Dao类继承HibernateDaoSupport后出现异常

异常:'sessionFactory' or 'hibernateTemplate' is required

原因:未注入hibernateTemplate,需要在spring的配置文件中明确指定bean以byName的方式匹配

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
"
default-autowire="byName" >

原文地址:https://www.cnblogs.com/lmq-1048498039/p/6949581.html