错误全部信息为:Caused by: java.lang.IllegalArgumentException: Mapping directory location [URL [file:/C:/apache-tomcat-6.0.30/webapps/SSH_Basic/WEB-INF/classes/com/student/model/Student.hbm.xml]] does not denote a directory
原因:
ApplicationContext.xml中配置hibernate配置有三种方式
如果配置错了、把mappingDirectoryLocations value配置成了mappingLocations的 value 会报上述错误
1、配置目录
<property name="mappingDirectoryLocations">
<list>
<!-- 用户hbm配置 -->
<value>classpath:com/cuser/model</value>
<!-- 学生hbm配置 -->
<value>classpath:com/student/model</value>
</list>
</property>
2、配置文件
<property name="mappingLocations">
<list>
<value>classpath:com/cuser/model/*.hbm.xml</value>
<value>classpath:com/student/model/*.hbm.xml</value>
</list>
</property>
3、配置jar
<property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/jarName.jar</value>
</list>
</property>
欢迎加我的qq技术群425783133