Org.hibernate.MappingException:invalid Configuration

Source: Internet
Author: User

Write the Hello World of Hibernate
The content is very simple, an entity Bean--student.java
A test file--studenttest.java
Two configuration files: Student.hbm.xml,hibernate.cfg.xml


But always error:
Exception in thread "main" Org.hibernate.MappingException:invalid configuration
caused by:org.xml.sax.SAXParseException; Linenumber:3; columnnumber:25; Invalid document: syntax not found.


I am really confused ah, are simple to not simple things, also reported wrong, but also clearly know that the configuration file is wrong, and then suspect that the problem is a jar package, there is doubt that the test was written wrong.


This evening myeclipse sudden kindness, incredibly give me a very detailed hint, clearly pointed out is hibernate.cfg.xml the second line error.


I then went to Hibernate's reference document to put their configuration files throughout the exam, and then modify, and then test incredibly gorgeous passed.


Sure enough, Hibernate.cfg.xml's file header went wrong.


The original file header is:
<?xml version= "1.0" encoding= "Utf-8"?>

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" >


The following changes are:
<?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" >


Conclusion:
Can no longer go to other places to test the configuration file, the previous configuration file I copied from a project. It's better to go straight to the documentation.

Org.hibernate.MappingException:invalid Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.