`
huiqinbo
  • 浏览: 334371 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

beans.xml配置多个hbm.xml

阅读更多
java开源框架应用技巧之spring配置文件中如果有多个.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错 收藏
问题描述:
在spring配置文件中如果有多个*.hbm.xml文件的话,无论是项目开发过程中还是维护过程中修改起来都会很麻烦切容易出错
这时我们可以把name="mappingResources"改为name="mappingDirectoryLocations",然后只需要配置*.hbm.xml文件所在目录就行了


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource"></property>
  <!--<property name="mappingResources">
   <list>
    <value>classpath:/com/crm/entity</value>
     <value>com/crm/entity/BasDict.hbm.xml</value>
    <value>com/crm/entity/CstActivity.hbm.xml</value>
    <value>com/crm/entity/CstCustomer.hbm.xml</value>
    <value>com/crm/entity/CstLinkman.hbm.xml</value>
    <value>com/crm/entity/CstService.hbm.xml</value>
    <value>com/crm/entity/SalChance.hbm.xml</value>
    <value>com/crm/entity/SalPlan.hbm.xml</value>
    <value>com/crm/entity/SysRight.hbm.xml</value>
    <value>com/crm/entity/SysRole.hbm.xml</value>
    <value>com/crm/entity/SysRoleRight.hbm.xml</value>
    <value>com/crm/entity/SysUser.hbm.xml</value>
    <value>com/crm/entity/VOrders.hbm.xml</value>
    <value>com/crm/entity/VOrdersLine.hbm.xml</value>
    <value>com/crm/entity/VProduct.hbm.xml</value>
    <value>com/crm/entity/VStorage.hbm.xml</value>
   </list>
  </property>-->
  <property name="mappingDirectoryLocations">
   <list>
    <value>classpath:/com/crm/entity</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <value>
    <!-- hibernate.dialect=org.hibernate.dialect.MySQLDialect -->
    hibernate.dialect=org.hibernate.dialect.SQLServerDialect
    hibernate.hbm2dll.auto=update
    hibernate.show_sql=true
    hibernate.format_sql=true
   </value>
  </property>
</bean>

分享到:
评论

相关推荐

    ssh框架在application.xml中配置数据源所需jar

    &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!-- - Application context definition for JPetStore's business layer. - Contains bean references to the transaction manager and to the DAOs in - ...

    halloworld

    ..........\...\..\..\persist\Xiangmubiao.hbm.xml ..........\...\..\..\.......\Xiangmubiao.java ..........\...\..\..\server\server.java ..........\...\hibernate.cfg.xml ..........\...\struts.xml ...

    客户关系管理系统框架搭建(二)

    * 创建hibernate.cfg.xml文件连接数据库,加载SysUserGroup.hbm.xml文件,放置src下 &lt;property name="hibernate.connection.username"&gt;root &lt;property name="hibernate.connection.password"&gt;root ...

    spring3.2+strut2+hibernate4

    &lt;constant name="struts.counfiguraction.xml.reload" value="true"/&gt; &lt;!-- 指定浏览器输出的编码格式 --&gt; &lt;constant name="struts.il8n.encoding" value="utf-8"/&gt; &lt;!--将action内容放在package元素下,...

    spring_MVC源码

    -- 这里在配成spring,下边也要写一个名为spring-servlet.xml的文件,主要用来配置它的controller --&gt; 19. *.do&lt;/url-pattern&gt; 20. &lt;/servlet-mapping&gt; 21. &lt;welcome-file-list&gt; 22. &lt;welcome-file&gt;index.jsp...

    ssh(structs,spring,hibernate)框架中的上传下载

    WEB-INF下的applicationContext.xml为Spring的配置文件,struts-config.xml为Struts的配置文件,file-upload.jsp为文件上传页面,file-list.jsp为文件列表页面。  本文后面的章节将从数据持久层->业务层->Web层的...

    Spring + Hibernate + Struts 事务配置小例子(带提示框等小技巧)

    &lt;value&gt;com/bean/Tuser.hbm.xml&lt;/value&gt; &lt;prop key="hibernate.dialect"&gt; org.hibernate.dialect.OracleDialect &lt;prop key="hibernate.show_sql"&gt;true ...

    ssh 整合的实例-----员工表的增删查改

    &lt;value&gt;com/mysteelsoft/entity/Employee.hbm.xml&lt;/value&gt; &lt;prop key="hibernate.show_sql"&gt;true &lt;prop key="hibernate.format_sql"&gt;true &lt;prop key="hibernate.dialect"&gt; org....

    JdbcTemplateTool.zip

    比如你没法像hibernate那样直接传一个对象给它让他拆分成sql并保存起来,当然这也是可以理解的,毕竟它并没有要求你去写 hbm.xml 文件所以无法知道你哪些字段要映射,哪些不要等等。又比如JdbcTemplate 可以帮忙把一...

    维生药业小项目 SSH简单学习项目

    &lt;prop key="hibernate.hbm2ddl.auto"&gt;update &lt;value&gt;com.sixth.**.model &lt;!-- 事务配置 --&gt; class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;!-...

Global site tag (gtag.js) - Google Analytics