Mybatis 绑定异常,Invalid bound statement (not found)

qq_17551297 2018-03-15 12:30:55
dao和Mapper文件都是自动生成的确定没有错误,老是执行不成功。项目是Maven项目,编译后的目录也查看过,确定没问题。贴上图片。不知道为什么图片上传不成功,贴上配置信息。


<!-- Mybatis文件 -->
<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- 配置Mybatis核心配置文件所在位置 -->
<property name="configLocation" value="classpath:mybatis-config.xml" />

</bean>

<!-- 接口 Mapper 扫描方式 自动 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 扫描的包 -->
<property name="basePackage" value="test.dao, test.service" />
</bean>


出错信息,提示是service层出错,顺便贴上service层代码

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): test.service.UserTableService.selectByPrimaryKey
org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
com.sun.proxy.$Proxy23.selectByPrimaryKey(Unknown Source)
test.controller.SelectProject.selectProject(SelectProject.java:26)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)




代码


/**
* 用户信息表操作
* @author
*
*/
@Service
@Transactional
public class UserTableServiceImpl implements UserTableService {

@Autowired
private UserTableMapper userTableDao;

public UserTable selectByPrimaryKey(Integer userId) {
return userTableDao.selectByPrimaryKey(userId);
}

@Override
public int insert(UserTable record) {
return userTableDao.insert(record);
}



...全文
903 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_17551297 2018-03-28
  • 打赏
  • 举报
回复
感谢回答,这个问题弄了半天不想弄了,重新搭建了一次框架。好了
__san_niu_m 2018-03-15
  • 打赏
  • 举报
回复
dao方法和mapping文件没有对应上 1.检查包名是否错误 2.检查mapping文件最上面对应dao是否写错 3.mapping中selectByPrimaryKey 是否存在
Sunyiban 2018-03-15
  • 打赏
  • 举报
回复
Invalid bound statement (not found): test.service.UserTableService.selectByPrimaryKey 看看你这个方法的返回值类型对了没
hsxing123 2018-03-15
  • 打赏
  • 举报
回复
还是看一下Dao和Mapping文件,看错误,应该是Dao的方法和Mapping文件没对应上

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧