HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingEx

 

今天遇到一個問題,IntelliJ IDEA 開發Spring-mvc +mybits 項目,本機配置jetty沒爲題,可是配置tomcat8居然錯誤了。java

問題以下:web

HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo


type Exception report

message Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo

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.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
    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)
root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.creditease.proxymanager.dao.ProxyInfoDAO.getProxyInfo

 

網上搜了一下,問題出在沒找到Mapper XML 文件spring

查看applicationcontent.xml 文件發現:sql

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:sqlmap-config.xml"/>
   
    </bean>

 

添加以下配置:數據庫

<property name="mapperLocations" value="classpath:com/creditease/proxymanager/dao/*.xml"/>
com/creditease/proxymanager/dao/*.xml 就是xml文件地址

正確配置以下
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:sqlmap-config.xml"/>
        <property name="mapperLocations" value="classpath:com/creditease/proxymanager/dao/*.xml"/>
    </bean>
sqlmap-config.xml 配置以下,
com.creditease.proxymanager.dao.dto 是數據庫表對應的實體類路徑
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <typeAliases>
        <package name="com.creditease.proxymanager.dao.dto"/>
      </typeAliases>
</configuration>

 

全部配置信息我就不貼了。apache

相關文章
相關標籤/搜索