您的位置:首页 > 运维架构 > Apache

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

2018-01-06 14:48 519 查看
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中映射实体类不写包名,需要配置别名

[html] view
plain copy

<!--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等。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  SSM
相关文章推荐