Since spring integrates fairly well with the Hibernate profile Hibernate.cfg.xml,
I've been using Spring's org.springframework.orm.hibernate.LocalSessionFactoryBean to replace the features of hibernate.cfg.xml files in my project Localsessionfactorybean has several properties for finding hibernate mapping files: mappingresources, Mappinglocations, Mappingdirectorylocations and mappingjarlocations Their differences: mappingresources: Specify classpath under specific mapping file name <property name= " Mappingresources "> <value>petclinic.hbm.xml </value> </property> mappinglocations: You can specify any file path, And you can specify the prefix: classpath, file, <property name= "mappinglocations" > <value>/web-inf/petclinic.hbm.xml </ value> </property> <property name= "Mappinglocations" > <value>classpath:/com/company/domain/pe Tclinic.hbm.xml </value> </property> can also be specified with wildcard characters, ' * ' to specify a file (path) name, ' * * ' to specify multiple file (path) names, such as: <property name= " Mappinglocations "> <value>classpath:/com/company/domainmaps/*.hbm.xml </value> </property> Top The configuration is that hbm.xml files under any maps path under the Com/company/domain package are loaded as map file mapPingdirectorylocations: Specifies the mapped file path <property name= "Mappingdirectorylocations" > <list> <value>web-i Nf/hibernatemappings</value> </list> </property> can also be classpath to point out <property name= " Mappingdirectorylocations "> <list> <value>classpath:/XXX/package/</value> </list> </
Property> mappingjarlocations: Specifies that the loaded mapping file is in the jar file