applicationContext.xml中使用一下两个类来配置的
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">和
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

解决方案 »

  1.   

    <!--读取cfg.properties-->    
        <bean id="propertyConfigurer"  
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
       <property name="locations">   
                <list>   
                    <value>classpath:cfg.properties</value>
                </list>   
      </property>  
       </bean>
       
         <bean id="dataSource" name="dataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" >
    <property name="user" value="${accUser.jdbc.user}"></property>
    <property name="password" value="${accUser.jdbc.password}"></property>
    <property name="jdbcUrl" value="${accUser.jdbc.jdbcUrl}"></property>
    <property name="driverClass" value="${accUser.jdbc.driverClass}"></property>
    <property name="maxPoolSize" value="${accUser.jdbc.poolmax}"></property>
    <property name="minPoolSize" value="${accUser.jdbc.poolmin}"></property>
    <property name="initialPoolSize" value="${accUser.jdbc.poolinit}"></property>
      </bean> 
              
      <bean id="txManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
      </bean>      
      <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
             <property name="dataSource">
                <ref local="dataSource" />
             </property>
             <property name="mappingResources">
                <list>
                   <value>com/mvc/events/Event.hbm.xml</value>
                </list>
             </property>
             <property name="hibernateProperties">
                <props>
                   <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                   <prop key="hibernate.show_sql">true</prop>
                   <prop key="current_session_context_class">thread</prop>
               <prop key="hbm2ddl.auto">create</prop> 
               <prop key="max_fetch_depth">1</prop>
                </props>
             </property>  
           </bean>