<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<!-- 方言 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<!-- 顯示sql語句 -->
<prop key="hibernate.show_sql">true</prop>
<!-- 格式化sql語句 -->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingLocations" value="classpath:com/hncj/crm/*/domain/*.hbm.xml"></property>
</bean>spring
//*************************************************************************************************************************sql
上面這段配置中一直拋出一下異常session
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 XMLapp
弄了一上午也找不到緣由,頭都炸了dom
後面看到一個貼說是*.hbm.xml 中內容有錯,我就一行一行檢查,但是仍是沒發現有什麼錯誤,最後。。。。。。最後,居然是由於dtd後面多以一個空格致使的spa
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd ">把dtd後面的空格刪除,就把問題解決了hibernate