The method getHibernateTemplate() is undefined for the type XX,该如何解决

The method getHibernateTemplate() is undefined for the type XXXML code?xml version1.0 encoding

The method getHibernateTemplate() is undefined for the type XX

XML code
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"    xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd   http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"><!-- dataSource -->    <bean id="dataSource"        class="org.springframework.jdbc.datasource.DriverManagerDataSource">        <property name="driverClassName" value="com.mysql.jdbc.Driver" />        <property name="url"            value="jdbc:mysql://localhost:3306/qq?autoReconnect=true&amp;useUnicode=true&amp;characterEncodingutf-8" />        <property name="username" value="root" />        <property name="password" value="123456" />    </bean>    <!-- sessionFactory -->    <bean id="sessionFactory"        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">        <property name="dataSource" ref="dataSource" />        <property name="hibernateProperties">            <props>                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>                <prop key="hibernate.show_sql">true</prop>            </props>        </property>        <property name="mappingResources">            <list>                <value>com/entity/A.hbm.xml</value>                <value>com/entity/B.hbm.xml</value>                <value>com/entity/C.hbm.xml</value>            </list>        </property>        <property name="packagesToScan">            <list>                <value>com.entity</value><!-- 扫描实体类,也就是平时所说的model -->            </list>        </property>    </bean><bean        class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />    <context:component-scan base-package="com.entity" /> <!-- 自动扫描所有注解该路径,NIBIE -->    <!-- transaction -->    <bean id="transactionManager"        class="org.springframework.orm.hibernate3.HibernateTransactionManager">        <property name="sessionFactory" ref="sessionFactory" />    </bean>    <!-- implements -->    <bean id="ADAO" class="com.dao.ADAO">        <property name="sessionFactory">            <ref bean="sessionFactory" />        </property>    </bean>    <bean id="CDAO" class="com.dao.CDAO">        <property name="sessionFactory">            <ref bean="sessionFactory" />        </property>    </bean>    <bean id="BDAO" class="com.dao.BDAO">        <property name="sessionFactory">            <ref bean="sessionFactory" />        </property>    </bean>    <bean id="DServer" class="com.server.DServer">        <property name="dao">            <ref bean="BDAO" />        </property>    </bean>    <tx:annotation-driven transaction-manager="transactionManager" />    <tx:annotation-driven mode="aspectj" /> 


</beans>

JAVA测试类获取dao保存数据都没有问题,使用页面保存在获取调用dao时就出现dao对象为空!

 

public class DServer {

private BDAO dao;
 
 
public BDAO getBDao() {
return dao;
}


public void setDao(BDAO dao) {
this.dao = dao;
}


public boolean save(C obj){
System.out.println(dao);
System.out.println(obj);
dao.save(obj);

return true;
}

}

异常:
The method getHibernateTemplate() is undefined for the type DServer ??



[解决办法]
<bean id="BDAO" class="com.dao.BDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="DServer" class="com.server.DServer">
<property name="dao">
<ref bean="BDAO" />
</property>
 </bean>
换个名字试一试

[解决办法]
你的dao应该继承实现hibernate的相应类才可以吧