zoukankan      html  css  js  c++  java
  • Mapper.xml文件报错

    HTTP Status 500 - Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 121; columnNumber: 10; 元素类型为 "mapper" 的内容必须匹配 "(cache-ref|cache|resultMap*|parameterMap*|sql*|insert*|update*|delete*|select*)+"。
    type Exception report message Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
    'sqlSessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 121; columnNumber: 10; 元素类型为 "mapper" 的内容必须匹配 "(cache-ref|cache|resultMap*|parameterMap*|sql*|insert*|update*|delete*|select*)+"。 description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 121; columnNumber: 10; 元素类型为 "mapper" 的内容必须匹配 "(cache-ref|cache|resultMap*|parameterMap*|sql*|insert*|update*|delete*|select*)+"。 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) javax.servlet.http.HttpServlet.service(HttpServlet.java:648) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107
    
    

    原因:Mapper.xml中SQL语句出错

    错误代码如下

          <!-- 执行分页查询 -->
       <select id="selectAllContacts" resultMap="BaseResultMap" parameterType="cn.ma.spring.po.Contacts" resultType="Integer">
        select * from contacts
        <include refid="Base_Column_List"></include>
    
      </select>
        
        <if test="start !=null and rows != null">
            limit #{start},#{rows}
        </if>

    修正如下:

          <!-- 执行分页查询 -->
       <select id="selectAllContacts" resultMap="BaseResultMap" parameterType="cn.ma.spring.po.Contacts" resultType="Integer">
        select * from contacts
        <include refid="Base_Column_List"></include>
        <if test="start !=null and rows != null">
            limit #{start},#{rows}
        </if>
      </select>

    总结: limit #{start},#{rows}语句应放入select 标签下

  • 相关阅读:
    埋点
    go 搭建web服务
    go的常见操作
    Zeus资源调度系统介绍
    支付系统中热点账户的性能问题
    redis
    集成Spring-Boot与gRPC,grpc-spring-boot-starter
    Spring Cloud灰度发布之Nepxion Discovery
    Spring Cloud Stream
    通过消息总线Spring Cloud Bus实现配置文件刷新(使用Kafka或RocketMQ)
  • 原文地址:https://www.cnblogs.com/axibug/p/12992493.html
Copyright © 2011-2022 走看看