• 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

    以粮为纲全面发展
  • 相关阅读:
    JS——ajax login test
    Java——Java日期转Sql日期
    JDK动态代理实现原理
    Java 动态代理机制分析及扩展,第 1 部分
    Java枚举类
    Java强引用、 软引用、 弱引用、虚引用
    取模运算
    java集合框架
    字节和unicode
    编译原理随笔
  • 原文地址:https://www.cnblogs.com/alexliuf/p/13620894.html
Copyright © 2020-2023  润新知