<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