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文件

posted @ 2017-04-26 21:26  归零,路上  阅读(493)  评论(0编辑  收藏  举报