异常 Java Error instantiating class com.zb.entity.Admin xxx with invalid types () or values ()
程序员文章站
2022-07-14 17:12:44
...
异常 Java Error instantiating class com.zb.entity.Admin xxx with invalid types () or values ()
SDK:1.6,Mycelipse10 , Mysql数据库
Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.zb.entity.Admin with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.zb.entity.Admin.<init>()
### The error may exist in com/zb/entity/AdminMapper.xml
### The error may involve com.zb.mapper.AdminMapper.login-Inline
### The error occurred while setting parameters
### SQL: SELECT * FROM `admin` WHERE `adminId` = ? AND `adminPwd` = ?
### Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.zb.entity.Admin with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.zb.entity.Admin.<init>()
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:62)
at com.zb.mapper.AdminMapper.login(AdminMapper.java:12)
at com.zb.test.Test.main(Test.java:13)
Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.zb.entity.Admin with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.zb.entity.Admin.<init>()
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:83)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:45)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:38)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:386)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.createResultObject(FastResultSetHandler.java:365)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.getRowValue(FastResultSetHandler.java:261)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleRowValues(FastResultSetHandler.java:216)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSet(FastResultSetHandler.java:188)
at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleResultSets(FastResultSetHandler.java:154)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:57)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
... 4 more
Caused by: java.lang.NoSuchMethodException: com.zb.entity.Admin.<init>()
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:57)
... 20 more
以下内容摘自:https://blog.csdn.net/pansanday/article/details/50389906
1. model中的get/set方法与成员变量不一。
2. 构造函数被重载过,但是没有空的构造函数。(此为本人错误所在)
3. 最好不要使用简单类型,如int, long等,改用对象模式Integer, Long等。在写条件查询时会用到判断<if xxx != null > … </if>的
上一篇: 后台上传图片异常
下一篇: 项目跨域问题处理方法