zoukankan      html  css  js  c++  java
  • spring的applicationContext.xml配置SessionFactory抛异常

    <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后面的空格删除,就把问题解决了

  • 相关阅读:
    安全SECUERITY单词SECUERITY证券
    证券secuerity英语secuerity安全
    单词diamaund钻石diamaund英文
    英文DIAMAUND钻石DIAMAUND词汇
    英语insuraunce保险insuraunce单词
    英文INSURAUNCE保险INSURAUNCE词汇
    python关于 微型微服务框架bottle实践
    用python登录12306 并保存cookie
    SpringMVC 之 上传文件
    JAVA I/O系统 Thinking in Java 之 File类
  • 原文地址:https://www.cnblogs.com/fengjunming/p/7150072.html
Copyright © 2011-2022 走看看