<!-- 这里一定要注意是使用spring的mappingLocations属性进行通配的 -->
      <property name="mappingLocations">
         <list>
            <value>classpath:/com/model/domain/*.hbm.xml</value>

</list>
      </property>

-----------------------------------------

spring整合hibernate配置文件中的sessionfactory中,配置映射文件有好多种方法:

LocalSessionFactoryBean有好几个属性用来查找hibernate映射文件:mappingResources、mappingLocations、mappingDirectoryLocations与mappingJarLocations。

他们的区别:
mappingResources:指定classpath下具体映射文件名
<property name="mappingResources">
  <value>petclinic.hbm.xml</value>
</property>

mappingLocations:可以指定任何文件路径,并且可以指定前缀:classpath、file等
<property name="mappingLocations">
  <value>/WEB-INF/petclinic.hbm.xml</value>
</property>

<property name="mappingLocations">
  <value>classpath:com/company/domain/petclinic.hbm.xml</value>
</property>
也可以用通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名,例如:
<property name="mappingLocations">
  <value>classpath:com/company/domain/**/maps/*.hbm.xml</value>
</property>
上面的配置是在com/company/domain包下任何maps路径下的hbm.xml文件都被加载为映射文件mappingDirectoryLocations:指定映射的文件路径
mappingJarLocations:指定加载的映射文件在jar文件中

注意:当有mappingLocations存在时,mappingResources中对hibernate映射文件的配置是不加载的,因此,需要把映射文件配置都放到mappingLocations中

spring配置hibernate映射文件-------通配符的更多相关文章

  1. Spring集成Hibernate映射文件的4种方式

    概要: 在Spring的applicationContext.xml中集成Hibernate映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少 ...

  2. 用Spring的mappingDirectoryLocations来配置Hibernate映射文件

    在Spring的applicationContext.xml中配置映射文件的方法: <property name="mappingResources">     < ...

  3. SSH整合,applicationContext.xml中配置hibernate映射文件问题

    今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...

  4. spring配置和映射文件

    配置 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www. ...

  5. spring引用hibernate映射文件的四种方式

    1.mappingResources 2.mappingLocations 3.mappingDirectoryLocations 4.mappingJarLocations 四种方式:https:/ ...

  6. spring加载hibernate映射文件的几种方式。转自:http://blog.csdn.net/huiwenjie168/article/details/7013618

    在Spring的applicationContext.xml中配置映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少时,可以用sessionF ...

  7. spring加载hibernate映射文件的几种方式 (转)

    在Spring的applicationContext.xml中配置映射文件,通常是在<sessionFactory>这个 Bean实例中进行的,若配置的映射文件较少时,可以用session ...

  8. 文件映射spring 使用classpath方式加载hibernate映射文件

    在改章节中,我们主要介绍文件映射的内容,自我感觉有个不错的建议和大家分享下 <!-- 批量指定到classpath下面 --> <property name="mappin ...

  9. spring加载hibernate映射文件的几种方式

    1. 在Spring的applicationContext.xml中配置映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少时,可以用sessi ...

随机推荐

  1. Scala之模式匹配(Patterns Matching)

    前言 首先.我们要在一開始强调一件非常重要的事:Scala的模式匹配发生在但绝不仅限于发生在match case语句块中.这是Scala模式匹配之所以重要且实用的一个关键因素!我们会在文章的后半部分具 ...

  2. 《从零开始学Swift》学习笔记(Day 35)——会使用下标吗?

    原创文章,欢迎转载.转载请注明:关东升的博客 看下面的示例代码是不是使用过: var studentList: String[] = ["张三","李四",&q ...

  3. cocos2d-x设计模式发掘之三:管理者模式

      作者 firedragonpzy    地址:http://www.firedragonpzy.com.cn/index.php/archives/2103 想必读者一看这个题目又要纳闷了,神马又 ...

  4. 迷宫问题(java实现)

    1. public class Direction { private int x; private int y; public Direction(int x, int y) { this.x = ...

  5. Decimal fixed point and floating point arithmetic

    decimal — Decimal fixed point and floating point arithmetic — Python 3.8.0a0 documentation https://d ...

  6. ThinkPHP的join方法

    两张表: 表一:pre_company_member 关联字段:comp_id 表二:pre_company  关联字段:comp_id 查询这两表中的数据. 方法一:驼峰法 $member=M('C ...

  7. python函数回顾:dir()

    描述 dir() 函数不带参数时,返回当前范围内的变量.方法和定义的类型列表: 带参数时,返回参数的属性.方法列表.如果参数包含方法__dir__(),该方法将被调用. 如果参数不包含__dir__( ...

  8. Python3.6全栈开发实例[020]

    20.判断一个数是否是水仙花数, 水仙花数是一个三位数, 三位数的每一位的三次方的和还等于这个数. 那这个数就是一个水仙花数, 例如: 153 = 1**3 + 5**3 + 3**3 num = i ...

  9. MySQL第一天

    数据库课程体系 在PHP阶段,将数据库分为三个阶段:     基础阶段(就业班第一个阶段): 6天, mysql数据库的基本操作(增删改查), 以及一些高级操作(视图, 触发器,函数,存储过程等), ...

  10. boost之string_algo

    string_algo是用于处理字符串查找,替换,转换等一系列的字符串算法 前缀i:表示大小写不敏感 后缀_copy:表示不变动输入,返回处理结果的拷贝 后缀_if:表示算法需要一个判断式的谓词函数对 ...