mybatis报错 Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values ()

错因在于把

<association property="dept"
select="com.atguigu.mybatis.dao.DepartmentMapper.getDeptById"
column="d_id">
</association>

写成了

<association property="dept"
javaType="com.atguigu.mybatis.dao.DepartmentMapper" column="d_id">
</association>

初学mybatis的鉴别器,不懂,所以搞错。

完整报错如下所示:

org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis.dao.DepartmentMapper.<init>()
### The error may exist in com/atguigu/mybatis/dao/EmployeeMapperPlus.xml
### The error may involve com.atguigu.mybatis.dao.EmployeeMapperPlus.getEmpByIdStep
### The error occurred while handling results
### SQL: select * from tbl_employee where id=?
### Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis.dao.DepartmentMapper.<init>()
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:82)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy9.getEmpByIdStep(Unknown Source)
at com.atguigu.mybatis.test.MyBatisTest.test05(MyBatisTest.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.atguigu.mybatis.dao.DepartmentMapper.<init>()
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:90)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:50)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:42)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:597)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:574)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:853)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyNestedResultMappings(DefaultResultSetHandler.java:907)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:862)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForNestedResultMap(DefaultResultSetHandler.java:825)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:311)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:286)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:183)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
... 29 more
Caused by: java.lang.NoSuchMethodException: com.atguigu.mybatis.dao.DepartmentMapper.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:62)
... 48 more

原文地址:https://www.cnblogs.com/liaoxiaolao/p/9979268.html

时间: 2024-10-30 14:12:49

mybatis报错 Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values ()的相关文章

使用mybatis报错constructor found in com.atguigu.mybatis.bean.Department matching [java.lang.Integer, java.lang.String]

报错constructor found in com.atguigu.mybatis.bean.Department matching [java.lang.Integer, java.lang.String] 构造方法不匹配,因为反射中会使用默认的无参构造器,而当我们一旦写了新的带参构造方法,那么就不会存在无参构造方法了,需要重新写过.自己在相应的实体中写一个无参构造方法就可以了. 完整报错如下所示: org.apache.ibatis.exceptions.PersistenceExcept

Mybatis报错 Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.me.mybatis.pojo.Orders with invalid types () or values ().

在学mybaits的时候遇到了这个错误,而且卡住了我三个小时也找不到,最后分析出来不能初始化类,然后就结合着之前自己以前的一点经验发现只有有参构造没有无参构造,因此只需要添加上无参构造就可以了. 错误源码 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Error ins

报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMapper is not known to the MapperRegistry.

我报这个错误的原因是因为mybatis-config.xml配置文件中 <!-- 批量注册: --> <package name="com.atguigu.mybatis.dao"/> 没有写对,根据路径改正就可以了.比如说应该写成 <package name="com.atguigu.mybatis.dao"/> 结果我写成了 <package name="com.atguigu.mybatis.bean.dao

AndroidStudio导入Eclipse项目报错Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject

AndroidStudio导入Eclipse项目报错 Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject 错误原因: Gradle插件版本不一致导致,问题多出现在:eclipse项目转studio 解决步骤: https://blog.csdn.net/qq_21397217/article/details/65630730 原文地址:https://www

MySQL登录报错ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/tmp/mysql.sock&#39; (2)

[[email protected] mysql3307]# /opt/mysql3307/bin/mysql -upisp [email protected]123 mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.so

springboot启动报错:&quot;Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.&quot;

报错内容 java.lang.Object.wait(Native Method)java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)2019-02-14 14:58:00.326 INFO 17688 --- [ main] Condition

mybatis报错:A query was run and no Result Maps were found for the Mapped Statement、、Property [login_ip] not found on type [com.thinkgem.jeesite.common.permission.entity.PremissUser]问题解决

今天在做ssm项目的时候出现了: 先是出现 了错误: mybatis报错:A query was run and no Result Maps were found for the Mapped Statement 这是因为Dao.xml中的select标签中必须指定要返回的值的类型(注意:是返回值的单个类型,即如果你是返回一个List<User>的话,需要指定的是User) 具体的这种错误的解决办法见:https://www.cnblogs.com/isme-zjh/p/11757155.h

git push报错error: failed to push some refs to &#39;[email&#160;protected]:

$ git push -u origin master To [email protected]:xxx/xxx.git ! [rejected] master -> master (fetch first) error: failed to push some refs to '[email protected]:xxx/xxx.git' hint: Updates were rejected because the remote contains work that you do hint:

Mysql多实例进入db报错ERROR 2002

今天做了mysql多实例实验, 进入3307没问题 进入3306: 进入: mysql -S /data/3306/mysql.sock报错: ERROR 2002 (HY000):Can't connect to local MySQL server 解决: 1. kill 33934 kill 34228 2, 我把启动脚本mysql中的密码去掉了 我把启动脚本mysql 统统chmod +x处理(之前是700) 3,重启 mysqld_safe --defaults-file=/data/