MyBatis Error: Org.apache.ibatis.exceptions.PersistenceException solution _mysql

Source: Internet
Author: User

MyBatis Error: Org.apache.ibatis.exceptions.PersistenceException solution

I. Description of the problem

Write the configuration file to test with JUnit, and the error will be the first run:

Org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause:org.apache.ibatis.reflection.ReflectionException:Error instantiating class Com.fendo.entity.Person with Invalid types () or values (). Cause:java.lang.nosuchmethodexception:com.fendo.entity.person.<init> () ### the error may exist in com/fendo/ Entity/person.xml ### The error may involve Defaultparametermap ### the error occurred while setting parameters ### SQL : SELECT * FROM person ### Cause:org.apache.ibatis.reflection.ReflectionException:Error instantiating class COM.FENDO.E Ntity. Person with invalid types () or values (). Cause:java.lang.nosuchmethodexception:com.fendo.entity.person.<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.binding.MapperMethod.executeForMany (mappermethod.java:114) at Org.apache.ibatis.binding.MapperMethod.execute (mappermethod.java:58) at Org.apache.ibatis.binding.MapperProxy.invoke (mapperproxy.java:43) at Com.sun.proxy. $Proxy 6.getPersons (Unknown Source) at Com.fendo.test.TestMybatis.test (testmybatis.java:40) at Sun.reflect.NativeMethodAccessorImpl.invoke0 ( Native to Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:62) at Sun.reflect.Dele Gatingmethodaccessorimpl.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.internal.runners.statements.RunBefores.evaluate (runbefores.java:26) at Org.junit.internal.runners.statements.RunAfters.evaluate (runafters.java:27) 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:675) 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 class Com.fendo.entity.Person with invalid Types () or values (). Cause:java.lang.nosuchmethodexception:com.fendo.entity.person.<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.DefaultResultSetHandler.createREsultobject (defaultresultsethandler.java:535) at Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject (Defaultresultsethandler.java : 514) at Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue (Defaultresultsethandler.java : 334) at Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap ( defaultresultsethandler.java:294) at 
  Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues (defaultresultsethandler.java:269) At Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet (Defaultresultsethandler.java : 239) at Org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets ( defaultresultsethandler.java:153) 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) ... caused By:java.lang.nosuchmethodexception:com.fendo.entity.person.<init> () at java.lang.Class.getCons Tructor0 (class.java:3082) at Java.lang.Class.getDeclaredConstructor (class.java:2178) at Org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass (defaultobjectfactory.java:57) ... 

 More

Ii. Solutions

From the above anomalies can be seen: java.lang.nosuchmethodexception:com.fendo.entity.person.<init> ()

Person this entity class can not initialize, could not initialize the reason is not constructed method, and then I looked at the next class does not have the construction method, for him to add a construction method, it is OK.

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.