当前位置: 首页> 房产> 政策 > MyBatis错误(二)

MyBatis错误(二)

时间:2025/7/13 17:40:42来源:https://blog.csdn.net/qq_42108331/article/details/141792003 浏览次数:0次

说明:记录一次MyBatis错误,错误信息如下:

2024-09-01 23:13:35.369 ERROR 7860 --- [nio-9090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hezy.repository.UserRepository.getLists] with root causeorg.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hezy.repository.UserRepository.getListsat org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.9.jar:3.5.9]at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) ~[mybatis-3.5.9.jar:3.5.9]at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:108) ~[mybatis-3.5.9.jar:3.5.9]at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]

说DAO没有找到绑定的标签

场景

就是很普通的一次列表查询,查询某张表的所有记录,如下:

(Controller)

    @GetMappingpublic List<User> getLists() {return userRepository.getLists();}

(DAO)

    List<User> getLists();

(动态SQL)

    <select id="getLists" resultType="java.util.List">select * from tb_user</select>

为什么会报没有找到绑定的statement

解决

resultType返回的对象类型,应该是实体类的全限定类名,而不是List,下面这样才是对的

    <select id="getLists" resultType="com.hezy.pojo.User">select * from tb_user</select>
关键字:MyBatis错误(二)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: