mybatis报错invalid types () or values ()解决方法

原因: Pojo类User没提供无参数构造方法, 加上该构造方法后,问题解决

引入lombok后直接加

@NoArgsConstructor
复制代码
### Cause: org.apache.ibatis.reflection.ReflectionException: 
Error instantiating class com.chry.browserServer.db.model.User with invalid types () or values (). 
cause: java.lang.NoSuchMethodException: com.chry.browserServer.db.model.User.<init>()] with root cause

java.lang.NoSuchMethodException: com.chry.browserServer.db.model.User.<init>()
    at java.lang.Class.getConstructor0(Class.java:2849) ~[na:1.7.0_67]
    at java.lang.Class.getDeclaredConstructor(Class.java:2053) ~[na:1.7.0_67]
    at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:57) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:45) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:38) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:387) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:366) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.getRowValue(FastResultSetHandler.java:266) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:221) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:193) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:159) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) ~[mybatis-3.2.1.jar:3.2.1]
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:62) ~[mybatis-3.2.1.jar:3.2.1]
。。。 。。。。

阅读更多
文章标签: mybatis
个人分类: java
上一篇@JsonInclude(Include.NON_NULL)
下一篇Maven 搭建spring boot多模块项目
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭