Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias

原文地址:点击打开链接

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blogServiceImpl': Unsatisfied dependency expressed through field 'blogDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blogDAO' defined in file [E:\1715\ssm-blog-admin\target\ssm-blog-admin\WEB-INF\classes\com\ssm\blog\dao\BlogDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\1715\ssm-blog-admin\target\ssm-blog-admin\WEB-INF\classes\com\ssm\blog\dao\mapper\BlogMappper.xml]'; nested exception is 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 'blogMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogMap
2018-01-06 11:38:20,931 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6dbb8301: defining beans [org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,dataSource,blogServiceImpl,categoryServiceImpl,keywordsServiceImpl,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,serviceMethod,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,blogDAO,categoryDAO,keywordsDAO]; root of factory hierarchy
2018-01-06 11:38:20,931 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blogServiceImpl': Unsatisfied dependency expressed through field 'blogDAO'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'blogDAO' defined in file [E:\1715\ssm-blog-admin\target\ssm-blog-admin\WEB-INF\classes\com\ssm\blog\dao\BlogDAO.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\1715\ssm-blog-admin\target\ssm-blog-admin\WEB-INF\classes\com\ssm\blog\dao\mapper\BlogMappper.xml]'; nested exception is 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 'blogMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: blogMap

ssm整合,tomcat启动的时候报错。出现 Could not resolve type alias 'blogMap'异常。出现这个异常的原因有可能有两个

1. 没有配置实体类的别名Alias,如果在mybatis的mapper中映射实体类不写包名,需要配置别名

    <!--spring管理session工厂-->  
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
            <property name="dataSource" ref="dataSource"/>  
            <property name="mapperLocations" value="classpath:com/ssm/blog/dao/mapper/*.xml"/>  
            <!--配置别名所在的包-->  
            <property name="typeAliasesPackage" value="com.ssm.blog.pojo"/>  
             
        </bean>  

2. resultMap和resultType写混了。通常这种情况会出现在select语句中。<select>标签的resultMap应该是mapper中<resultMap>的id,而resultType是一个具体的类型,也就是实体类的类名或者java基本数据类型int、long、string等。
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\]中的错误信息,出现了一个`org.apache.ibatis.builder.BuilderException`异常,其中包含了`Error resolving class`和`Could not resolve type alias`的错误。这个错误通常是由于无法解析类别名或找不到相应的类引起的。 根据引用\[2\]的建议,我们应该仔细检查相关的配置是否正确。首先,我们需要确认`mappers/user.xml`文件是否存在,并且路径是否正确。其次,我们需要检查`mybatis.config.xml`文件中是否包含了正确的类型别名配置。如果没有正确配置类型别名,MyBatis就无法解析类别名,从而导致找不到相应的类。 根据引用\[3\]的经验,你可能需要在`mybatis.config.xml`文件中添加以下语句来配置类型别名: ``` <typeAliases> <package name="com.kuang.pojo"/> </typeAliases> ``` 这样,MyBatis就能正确解析`UserDto`类的别名。 总结起来,出现`org.apache.ibatis.builder.BuilderException`异常的原因是无法解析类别名或找不到相应的类。你需要检查相关的配置文件,确保路径和类型别名的配置正确。如果仍然无法解决问题,你可以尝试重新查看相关的学习资料,或者寻求其他开发者的帮助。 #### 引用[.reference_title] - *1* [解决Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration错误](https://blog.csdn.net/weixin_45893072/article/details/122092416)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ···](https://blog.csdn.net/qq_52031643/article/details/120391273)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值