MyBatis错误之找不到实体类

错误:找不到实体类

解决办法:放错了包,在相应包的平行位置创建了相同的包所以找不到实体类

DEBUG [main] - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.baizhi.test.TestEmp.main(TestEmp.java:9)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### The error may exist in com/baizhi/dao/EmpDaoMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.baizhi.entity.Emp'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:54)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:38)
    at com.baizhi.MyBatisUtil.MyBatisUtil.<clinit>(MyBatisUtil.java:18)
    ... 1 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.baizhi.entity.Emp'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:109)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:92)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:52)
    ... 3 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.baizhi.entity.Emp'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:92)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:322)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:107)
    ... 5 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.baizhi.entity.Emp'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:103)
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:72)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:135)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
    ... 8 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.baizhi.entity.Emp'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:117)
    at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:130)
    at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:101)
    ... 12 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: com.baizhi.entity.Emp
    at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:190)
    at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
    at org.apache.ibatis.io.Resources.classForName(Resources.java:256)
    at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:113)
    ... 14 more

MyBatis错误之找不到实体类

 

上一篇:记录ibatis在项目中使用过的标签


下一篇:该驱动程序不支持 SQL Server 8 版