org.hibernate.MappingException: invalid configuration
来源:互联网 发布:淘宝怎么兑换虾米vip 编辑:程序博客网 时间:2024/05/08 04:37
写hibernate的hello world
内容非常简单,一个实体bean--Student.java
一个测试文件--StudentTest.java
两个配置文件:Student.hbm.xml,hibernate.cfg.xml
可是一直报错:
Exception in thread "main" org.hibernate.MappingException: invalid configuration
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; 文档无效: 找不到语法。
我实在是很困惑啊,都简单到不能简单的东西,还报错,也分明知道是配置文件的错,后来又怀疑是jar包的问题,有怀疑是测试写错了。
今天晚上myeclipse突发善心,居然给我很详细的提示,明确指出是hibernate.cfg.xml的第二行出错。
我于是去hibernate的参考文档中把他们的配置文件整个考过来,然后修改,再测试居然华丽丽的通过了。。
果然是hibernate.cfg.xml的文件头出错了。
原来的文件头是:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
修改之后的是:
<?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">
结论:
再也不能去其他地方乱考配置文件了,之前的配置文件就是我从一个项目里复制过来的。还是直接去文档里找比较好。
内容非常简单,一个实体bean--Student.java
一个测试文件--StudentTest.java
两个配置文件:Student.hbm.xml,hibernate.cfg.xml
可是一直报错:
Exception in thread "main" org.hibernate.MappingException: invalid configuration
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; 文档无效: 找不到语法。
我实在是很困惑啊,都简单到不能简单的东西,还报错,也分明知道是配置文件的错,后来又怀疑是jar包的问题,有怀疑是测试写错了。
今天晚上myeclipse突发善心,居然给我很详细的提示,明确指出是hibernate.cfg.xml的第二行出错。
我于是去hibernate的参考文档中把他们的配置文件整个考过来,然后修改,再测试居然华丽丽的通过了。。
果然是hibernate.cfg.xml的文件头出错了。
原来的文件头是:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
修改之后的是:
<?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">
结论:
再也不能去其他地方乱考配置文件了,之前的配置文件就是我从一个项目里复制过来的。还是直接去文档里找比较好。
0 1
- org.hibernate.MappingException: invalid configuration
- Exception in thread "main" org.hibernate.MappingException: invalid configuration
- org.hibernate.MappingException: invalid override definition
- org.hibernate.MappingException
- org.hibernate.MappingException
- org.hibernate.MappingException
- org.hibernate.MappingException:
- hibernate中 org.hibernate.MappingException
- hibernate 异常 org.hibernate.MappingException
- org.hibernate.MappingException: Unknown entity
- org.hibernate.MappingException: Unknown entity
- org.hibernate.MappingException: Unknown entity
- org.hibernate.MappingException: Unknown entity:
- org.hibernate.MappingException: …
- org.hibernate.MappingException: Unknown entity
- org.hibernate.MappingException:&…
- org.hibernate.MappingException: Unknown entity:
- org.hibernate.MappingException: Unknown entity:
- 黑马程序员——Java String、StringBuffer、StringBuilder、基本数据类型对象包装类
- 配置SpringMVC返回JSON遇到的坑
- 5555555555555555555555
- 新浪微博客户端详解(一)
- 我想成为的DBA或者想招到的DBA
- org.hibernate.MappingException: invalid configuration
- weixin sdk给.net人员的
- Android多线程Thread Runnable Handler AsyncTask等之间的关系
- 冯诺依曼体制
- 网络请求失败,点击按钮不响应事件
- 写Java程序的三十个基本规则
- LeetCode-Add Binary
- 第十四章 非阻塞I/O 和 记录锁
- Redis千万级的数据量的性能测试