java.lang.IllegalArgumentException: Mapping directory location[url ...]does not denote a directory

来源:互联网 发布:通联数据面经 编辑:程序博客网 时间:2024/06/06 13:10

错误全部信息为: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>
    

原创粉丝点击