日期:2014-05-19  浏览次数:20908 次

初学ssh配置,出错了,一直找不出原因
错误是:继承HibernateDaoSupport的UsersImpl获取到的getHibernateTemplate()一直没有值

 这是applicationContext的配置<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
       <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property>
       <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
       <property name="user" value="ssh"></property>
       <property name="password" value="ccb"></property>
       
       <property name="minPoolSize" value="1"></property>
       <property name="maxPoolSize" value="20"></property>
       <property name="initialPoolSize" value="1"></property>
       <property name="maxIdleTime" value="20"></property>      
    </bean>
    
    <!-- Hibernate的SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
       <property name="dataSource">
          <ref bean="dataSource"/>
       </property>
       <property name="hibernateProperties">
          <props>
             <prop key="hibernate.show_sql">true</prop>
             <prop key="hibernate.format_sql">true</prop>
             <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
          </props>
       </property>
       <property name="mappingResources">
          <list>
             <value>test1/po/Users.hbm.xml</value>
          </list>
       </property>
    </bean>

    <bean id="userDao" class="test1.impl.UsersImpl">
       <property name="sessionFactory"> 
          <ref bean="sessionFactory"/>
       </property>
    </bean>
   
    <bean id="mgr" class="test1.impl.UsersManagerImpl">
       <property name="userDao">
          <ref bean="userDao"/>
     &nb