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

原创 2016年11月26日 16:00:52

Exception in thread “main” org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.atguigu.mybatis_test.test1.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis_test.test1.User.()

The error may exist in com/atguigu/mybatis_test/test1/userMapper.xml

The error may involve com.atguigu.mybatis_test.test1.userMapper.getUser-Inline

The error occurred while setting parameters

SQL: select * from user where id=?

Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.atguigu.mybatis_test.test1.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis_test.test1.User.()

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)
at com.atguigu.mybatis_test.test1.Test.main(Test.java:25)

Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.atguigu.mybatis_test.test1.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis_test.test1.User.()
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:86)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:48)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:41)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:528)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:507)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:331)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:291)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:266)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:236)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:150)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:60)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:73)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:60)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
… 3 more
Caused by: java.lang.NoSuchMethodException: com.atguigu.mybatis_test.test1.User.()
at java.lang.Class.getConstructor0(Class.java:2810)
at java.lang.Class.getDeclaredConstructor(Class.java:2053)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:60)
… 20 more

异常处理方式:

  • model中的get/set方法与成员变量不一。对相应的变量添加getter和setter方法。
  • 构造函数重载过后,没有添加无参的构造函数。添加无参的构造函数。
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shuduti/article/details/53352425

WinCVS与CVSNT简明使用手则(一)

  WinCVS与CVSNT简明使用手则(作者:Jackey,网址:www.kuihua.net)1       前言:CVS是版本控制的利器,目前在Linux和Windows下都有不同版本;但是国内...
  • ycw
  • ycw
  • 2003-12-29 12:20:00
  • 6521

Error instantiating class with invalid types () or values ()

在使用mysql时,遇到了该错误,详细错误日志如下 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da...
  • pansanday
  • pansanday
  • 2015-12-23 21:41:21
  • 6516

Error instantiating class book.pojo.User with invalid types () or values (). 报错解决方法

错误提示代码: Error instantiating class book.pojo.User with invalid types () or values (). Cause: java.l...
  • baidu_32262373
  • baidu_32262373
  • 2016-03-01 20:12:10
  • 1671

Mybatis 报错Error instantiating class ---- with invalid types () or values ().

org.apache.ibatis.exceptions.PersistenceException:  ### Error querying database.  Cause: java.lang....
  • teliduxing_c
  • teliduxing_c
  • 2017-06-17 18:21:53
  • 279

mybatis映射问题,报错Error instantiating null with invalid types () or values (). Cause:java.lang.NullPoint

在用mybatis做关联查询,用association关联查询,报错Error instantiating null with invalid types () or values (). Cause...
  • likawei1314
  • likawei1314
  • 2017-03-25 03:31:39
  • 2059

Mybatis出错:Error instantiating class com.User with invalid types () or values ()

### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instant...
  • li330394383
  • li330394383
  • 2016-08-15 22:33:55
  • 4389

Mybatis出错:Error instantiating class xxx with invalid types () or values ()

写下这篇博客来警示自己: 今天配置mybatis出现这个错误 org.apache.ibatis.exceptions.PersistenceException: ### Error query...
  • zjkC050818
  • zjkC050818
  • 2017-07-05 15:13:50
  • 802

Error instantiating class com.ding.test.User with invalid types () or values (). Cause: java.lang.No

mybatis遇见错误: Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ###...
  • dingsai88
  • dingsai88
  • 2015-02-09 14:11:18
  • 4716

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

在使用ssm的时候,报了这个错 org.mybatis.spring.MyBatisSystemException:  nested exception is org.apache.ibatis....
  • zou2ouzou
  • zou2ouzou
  • 2017-04-25 18:58:15
  • 367

Myhabits报错invalid types () or values ()解决方法with invalid types () or values (). Cause: java.lang.NoSu

是报错信息: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection....
  • qq_25821067
  • qq_25821067
  • 2017-02-01 21:21:09
  • 408
收藏助手
不良信息举报
您举报文章:mybatis报错invalid types () or values ()解决方法
举报原因:
原因补充:

(最多只允许输入30个字)