MappingNotFoundException:资源:找不到user.hbm.xml [英] MappingNotFoundException: resource: user.hbm.xml not found

查看:51
本文介绍了MappingNotFoundException:资源:找不到user.hbm.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想使用jsp和hibernate制作用于用户注册表单的简单Web应用程序当我运行我的应用程序时,我正在关注Exeption

Hi i am tying to make simple web application for user registration form using jsp and hibernate When i run my application i am getting following Exeption

MappingNotFoundException: resource: user.hbm.xml not found

这是我的代码

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
**hibernate.cfg.xml**
    <hibernate-configuration>

          <session-factory>
            <property name="hbm2ddl.auto">update</property>
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="connection.url">jdbc:mysql://localhost:3306/employee</property>
            <property name="connection.username">root</property>
            <property name="connection.password"></property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="show_sql">true</property>
        <mapping resource="hiber/user.hbm.xml"/>
        </session-factory>

    </hibernate-configuration>

user.hbm.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

          <hibernate-mapping>
          <class name="User" table="u400">
          <id name="id">
          <generator class="increment"></generator>
          </id>
          <property name="name"></property>
          <property name="password"></property>
          <property name="email"></property>
          </class>
          </hibernate-mapping>

项目结构如下

 Project
    |
    |-WebPages
    |
    |-src
    |-hiber
    |  |-user.java
       |-UserDao.java
       |-user.hbm.xml
       |-hibernate.cfg.xml

如何删除此异常以及应该怎么做

How can i remove this Exception and what should i do

先谢谢了 遵循异常

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: org.hibernate.HibernateException: Could not parse configuration: /hiber/hibernate.cfg.xml

root cause

org.hibernate.HibernateException: Could not parse configuration: /hiber/hibernate.cfg.xml

root cause

org.dom4j.DocumentException: hibernate.sourceforge.net Nested exception: hibernate.sourceforge.net

推荐答案

检查hibernate的jar版本,并将其与hibernate.cfg.xml

check the jar version of hibernate and compare it with DTD version inside hibernate.cfg.xml

它应该基本匹配,否则无法解决依赖关系.

it should match basically otherwise it can not resolve the dependencies.

这篇关于MappingNotFoundException:资源:找不到user.hbm.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆