今天遇到一个问题,IntelliJ IDEA 开发Spring-mvc +mybits 项目,本机配置jetty没为题,但是配置tomcat8竟然错误了。
问题如下:
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 文件
查看applicationcontent.xml 文件发现:
<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>
所有配置信息我就不贴了。