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等。




  • 11
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

专治八阿哥的孟老师

您的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值