Java.lang.ClassNotFoundException:Cannot Find Class:user

Source: Internet
Author: User

Org.apache.ibatis.exceptions.PersistenceException:

# # # Error Building sqlsession.

# # # The error may exist in Dao/usermapper.xml

# # # Cause:org.apache.ibatis.builder.BuilderException:Error parsing SQL Mapper Configuration. Cause:java.lang.RuntimeException:Error parsing Mapper XML. Cause:org.apache.ibatis.builder.BuilderException:Error resolving class.  Cause:org.apache.ibatis.type.TypeException:Could not resolve type alias ' User '. Cause:java.lang.ClassNotFoundException:Cannot Find Class:user

At Org.apache.ibatis.exceptions.ExceptionFactory.wrapException (exceptionfactory.java:23)

At Org.apache.ibatis.session.SqlSessionFactoryBuilder.build (sqlsessionfactorybuilder.java:79)

At Org.apache.ibatis.session.SqlSessionFactoryBuilder.build (sqlsessionfactorybuilder.java:63)

At util. Mybatiesutil.<clinit> (MYBATIESUTIL.JAVA:16)

At Dao.impl.UserMapperImpl.count (usermapperimpl.java:18)

At Test. Usermapperimpltest.testcount (usermapperimpltest.java:15)

At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)

At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)

At Java.lang.reflect.Method.invoke (method.java:597)

At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:44)

At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)

At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:41)

At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)

At Org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (blockjunit4classrunner.java:79)

At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:71)

At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:49)

At Org.junit.runners.parentrunner$3.run (parentrunner.java:193)

At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:52)

At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:191)

At org.junit.runners.parentrunner.access$000 (parentrunner.java:42)

At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:184)

At Org.junit.runners.ParentRunner.run (parentrunner.java:236)

At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:50)

At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197)

caused By:org.apache.ibatis.builder.BuilderException:Error parsing SQL Mapper Configuration. Cause:java.lang.RuntimeException:Error parsing Mapper XML. Cause:org.apache.ibatis.builder.BuilderException:Error resolving class.  Cause:org.apache.ibatis.type.TypeException:Could not resolve type alias ' User '. Cause:java.lang.ClassNotFoundException:Cannot Find Class:user

At Org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration (xmlconfigbuilder.java:106)

At Org.apache.ibatis.builder.xml.XMLConfigBuilder.parse (xmlconfigbuilder.java:89)

At Org.apache.ibatis.session.SqlSessionFactoryBuilder.build (sqlsessionfactorybuilder.java:77)

... More

caused By:java.lang.RuntimeException:Error parsing Mapper XML. Cause:org.apache.ibatis.builder.BuilderException:Error resolving class.  Cause:org.apache.ibatis.type.TypeException:Could not resolve type alias ' User '. Cause:java.lang.ClassNotFoundException:Cannot Find Class:user

At Org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement (xmlmapperbuilder.java:113)

At Org.apache.ibatis.builder.xml.XMLMapperBuilder.parse (xmlmapperbuilder.java:88)

At Org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement (xmlconfigbuilder.java:317)

At Org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration (xmlconfigbuilder.java:104)

... More

caused by:org.apache.ibatis.builder.BuilderException:Error resolving class.  Cause:org.apache.ibatis.type.TypeException:Could not resolve type alias ' User '. Cause:java.lang.ClassNotFoundException:Cannot Find Class:user

At Org.apache.ibatis.builder.BaseBuilder.resolveClass (basebuilder.java:100)

At Org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode (xmlstatementbuilder.java:63)

At Org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext (xmlmapperbuilder.java:128)

At Org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext (xmlmapperbuilder.java:121)

At Org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement (xmlmapperbuilder.java:111)

... More

caused by:org.apache.ibatis.type.TypeException:Could not resolve type alias ' User '. Cause:java.lang.ClassNotFoundException:Cannot Find Class:user

At Org.apache.ibatis.type.TypeAliasRegistry.resolveAlias (typealiasregistry.java:114)

At Org.apache.ibatis.builder.BaseBuilder.resolveAlias (basebuilder.java:127)

At Org.apache.ibatis.builder.BaseBuilder.resolveClass (basebuilder.java:98)

... More

caused By:java.lang.ClassNotFoundException:Cannot find Class:user

At Org.apache.ibatis.io.ClassLoaderWrapper.classForName (classloaderwrapper.java:188)

At Org.apache.ibatis.io.ClassLoaderWrapper.classForName (classloaderwrapper.java:87)

At Org.apache.ibatis.io.Resources.classForName (resources.java:254)

At Org.apache.ibatis.type.TypeAliasRegistry.resolveAlias (typealiasregistry.java:110)

... More

Java.lang.NullPointerException

At util. Mybatiesutil.createsqlsession (mybatiesutil.java:23)

At Dao.impl.UserMapperImpl.count (usermapperimpl.java:18)

At Test. Usermapperimpltest.testcount (usermapperimpltest.java:15)

At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)

At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)

At Java.lang.reflect.Method.invoke (method.java:597)

At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:44)

At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)

At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:41)

At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)

At Org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (blockjunit4classrunner.java:79)

At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:71)

At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:49)

At Org.junit.runners.parentrunner$3.run (parentrunner.java:193)

At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:52)

At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:191)

At org.junit.runners.parentrunner.access$000 (parentrunner.java:42)

At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:184)

At Org.junit.runners.ParentRunner.run (parentrunner.java:236)

At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:50)

At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:467)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:683)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:390)

At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:197)

Count=-1


Error source code: User is the alias of class, need to set alias in Mybatis-config.xml

<insert id= "Add" parametertype= "User" >

Insert into User (Usercode,username,userpassword) values

(#{usercode},#{username},#{userpassword})

</insert>

Configure the following package aliases in the Mybatis-config.xml

<typeAliases>

<package name= "Com.news.entity"/>

</typeAliases>

You can also configure associated aliases

<typeAliases>

<typealias alias= "Author" type= "Domain.blog.Author"/>

<typealias alias= "Blog" type= "Domain.blog.Blog"/>

<typealias alias= "Comment" type= "Domain.blog.Comment"/>

<typealias alias= "Post" type= "Domain.blog.Post"/>

<typealias alias= "section" type= "Domain.blog.Section"/>

<typealias alias= "Tag" type= "Domain.blog.Tag"/>

</typeAliases>



Java.lang.ClassNotFoundException:Cannot Find Class:user

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.