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

阅读更多
 
Spring applicationContext.xml 中配置映射文件的方法:
name = "mappingResources" >
   
    com/almaer/model/Person.hbm.xml
    com/almaer/model/Car.hbm.xml
    com/almaer/model/Engine.hbm.xml
    com/almaer/model/Toy.hbm.xml
   
当配置文件变得越来越多,修改起来也越来越烦人,而且基于 XML 的配置也可能带来输入的错误,导致你可能因为一个字符的错误而找上半天。
现在,你只要指出文件夹就可以了, Spring 会替你找出所有映射文件
name = "mappingDirectoryLocations" >
   
       WEB-INF/mappings
   
也可以通过 classpath 来指出
name = "mappingDirectoryLocations" >
    
         classpath:/my/package/
    
 


你可能感兴趣的:(Spring,Hibernate,XML,Web)