<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>
//*************************************************************************************************************************
上面这段配置中一直抛出一下异常
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
弄了一上午也找不到原因,头都炸了
后面看到一个贴说是*.hbm.xml 中内容有错,我就一行一行检查,可是还是没发现有什么错误,最后。。。。。。最后,竟然是因为dtd后面多以一个空格导致的
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd ">把dtd后面的空格删除,就把问题解决了