mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations
他们的区别:
1. mappingResources:指定classpath下具体映射文件名
<property name="mappingResources">
<value>petclinic.hbm.xml </value>
</property>
2. 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/domainmaps/*.hbm.xml </value>
</property>
上面的配置是在com/company/domain包下任何maps路径下的hbm.xml文件都被加载为映射文件
3. mappingDirectoryLocations:指定映射的文件路径
<property name="mappingDirectoryLocations"> <list>
<value>WEB-INF/HibernateMappings</value>
</list>
</property>
也可以通过classpath来指出
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/XXX/package/</value>
</list>
</property>
mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations
最新推荐文章于 2019-09-09 18:13:53 发布
本文详细解析了Spring框架中的mappingResources、mappingLocations、mappingDirectoryLocations和mappingJarLocations的区别,包括它们如何指定类路径下的文件名、任意文件路径、目录路径以及jar包内的映射文件。
9578

被折叠的 条评论
为什么被折叠?



