zoukankan      html  css  js  c++  java
  • LocalSessionFactoryBean有几个属性查找hibernate映射文件

    LocalSessionFactoryBean有几个属性查找hibernate映射文件:

    mappingResources、mappingLocations、mappingDirectoryLocations与mappingJarLocations

    1、String[] mappingResources: 指定classpath下具体映射文件名

     
    1.             <property name="mappingResources">   
    2. <list>   
    3.     <value>cn/itcast/domain/User.hbm.xml</value>   
    4.     <value>cn/itcast/domain/Department.hbm.xml</value>   
    5. </list>   
    6. lt;/property>   

    2、Resource[] mappingLocations:指定任何文件路径,可以指定前缀:classpath、file等

    1. <propertynamepropertyname="mappingLocations"value="/WEB-INF/Pojot.hbm.xml"/>   
    2. <propertynamepropertyname="mappingLocations"value="classpath:cn/itcast/domain/User.hbm.xml"/>  
    3. 也可以用通配符指定,'*'指定一个文件(路径)名,'**'指定多个文件(路径)名,例如:  
    4.         <property name="mappingLocations">  
    5.             <list>  
    6.                 <value>classpath:cn/itcast/domain/*.hbm.xml</value>  
    7.             </list>  
    8.         </property>  

    3、Resource[] mappingDirectoryLocations:指定映射的文件路径

    1. <property name="mappingDirectoryLocations">  
    2.     <list>  
    3.         <value>/WEB-INF/classes/cn/itcast/domain</value>  
    4.     </list>  
    5. </property>  


    4、Resource[] mappingJarLocations:指定加载的映射文件在jar文件

  • 相关阅读:
    Linux基础
    杂谈
    MySQL基础
    Effective Java-第4章
    Effective Java-第三章
    Effective Java-第二章
    mybatis
    mapper.xml文件
    Mybatis
    mybatis-config.xml文件详解
  • 原文地址:https://www.cnblogs.com/writeLessDoMore/p/6771082.html
Copyright © 2011-2022 走看看