spring+hibernate 配置hibernate中的hbm.xml文件位置

 <!– Hibernate SessionFactory –>
   <bean id=”sessionFactory” class=”org.springframework.orm.hibernate.LocalSessionFactoryBean”>
        <property name=”dataSource”>
             <ref local=”dataSource”/>
      </property>
        <property name=”mappingResources”>
            <list>
               <value>adpinfo/model/Question.hbm.xml</value>
               <value>adpinfo/model/CustomerUser.hbm.xml</value>
            </list>
        </property>
        <property name=”hibernateProperties”>
        <props>
            <prop key=”hibernate.dialect”>net.sf.hibernate.dialect.OracleDialect</prop>
            
            <prop key=”hibernate.show_sql”>true</prop>
        </props>
        </property>
    </bean>
1.如上所示:定义mappingResources,每添加一个hbm.xml文件,在<list>中添加一条<value>记录
2.定义mappingDirectoryLocations指定文件所在目录:
<property name=”mappingDirectoryLocations”>
            <list>
               <value>classpath:adpinfo/model/</value>
            </list>
        </property>

发表回复

您的电子邮箱地址不会被公开。

昵称 *