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 标签下

  • 相关阅读:
    SSH的密钥登录配置
    VMware 15pro虚拟机网络设置
    12种SQL注入报错方式
    PHP myadmin 无路径getshell
    MySQL数据库基本操作
    ubuntu 16.04安装后的简单优化
    无聊中,静思自己。
    Silverlight 4.0+Linq to sql 网站后台登陆功能(一)
    AspNetPager和Linq to sql 的完美结合
    Linq to sql 的DataContext 持久化层写法
  • 原文地址:https://www.cnblogs.com/axibug/p/12992493.html
Copyright © 2011-2022 走看看