Spring's applicationcontext.xml configuration sessionfactory throw exception

Source: Internet
Author: User

<bean id= "sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean";
   <property name= "DataSource" ref= "DataSource" ></PROPERTY>
  <property name= " Hibernateproperties,
   <props>
    <!--dialect-->
    <prop key= "Hibernate.dialect" >org.hibernate.dialect.MySQL5Dialect</prop>
    <!--Display SQL statement-->
    <prop key= "Hibernate.show_sql" >TRUE</PROP>
    <!--formatted SQL statement-->
    <prop key= "Hibernate.format_sql" >TRUE</PROP>
   </props>
  </property
  <property name= "mappinglocations" value= "Classpath:com/hncj/crm/*/domain/*.hbm.xml" > </property>
 </bean>

//************************************************************************************************************* ************

The above configuration always throws an exception

Org.springframework.beans.factory.BeanCreationException:Error creating Bean with Name ' sessionfactory ' defined in Class path resource [Spring/applicationcontext.xml]: Invocation of Init method failed; Nested exception is org.hibernate.InvalidMappingException:Unable to read XML

I couldn't find a reason to do it all morning, and my head blew up.

Later saw a paste said is *.hbm.xml in the content of the wrong, I will check the line, but still did not find anything wrong, finally ... In the end, it was the result of more than one space behind the DTD.

<! DOCTYPE hibernate-mapping Public "-//hibernate/hibernate mapping DTD 3.0//en"
"HTTP://WWW.HIBERNATE.ORG/DTD/HIBERNATE-MAPPING-3.0.DTD" > Remove the space behind the DTD and solve the problem

Spring's applicationcontext.xml configuration sessionfactory throw exception

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.