Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘BaseResultMap’

  • Post author:
  • Post category:其他


艾玛,增加个功能,改了下配置,结果异常狂抛,百思不得解啊,百度了下,从一个老兄那得到了正解,记录下,少走弯路。。



异常信息如下:

  1. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean

    with

    name

    ‘sqlSessionFactory’

    defined

    in

    ServletContext resource [/WEB-INF/conf/spring-common.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource:

    ‘file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\XX\WEB-INF\classes\XXMapper.xml]’

    ; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving

    class

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

    ‘BaseResultMap’

    .  Cause: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  2. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
  5. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  6. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  9. at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
  10. … 29 more
  11. Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource:

    ‘file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\XX.xml]’

    ; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving

    class

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

    ‘BaseResultMap’

    .  Cause: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  12. at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:412)
  13. at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295)
  14. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
  15. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
  16. … 36 more
  17. Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving

    class

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

    ‘BaseResultMap’

    .  Cause: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  18. at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
  19. at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
  20. at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:410)
  21. … 39 more
  22. Caused by: org.apache.ibatis.builder.BuilderException: Error resolving

    class

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

    ‘BaseResultMap’

    .  Cause: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  23. at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:94)
  24. at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseS
  25. 2014-01-16 16:27:19,921 INFO [utils.init.CommonContextListener] – <CommonContextListener init listener begin.>
  26. tatementNode(XMLStatementBuilder.java:83)
  27. at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
  28. at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
  29. at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
  30. … 41 more
  31. Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias

    ‘BaseResultMap’

    .  Cause: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  32. at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:109)
  33. at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:115)
  34. at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:92)
  35. … 45 more
  36. Caused by: java.lang.ClassNotFoundException: Cannot find

    class

    : BaseResultMap
  37. at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
  38. at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
  39. at org.apache.ibatis.io.Resources.classForName(Resources.java:250)
  40. at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:105)
  41. … 47 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring-common.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\XX\WEB-INF\classes\XXMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
	... 29 more
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\XX.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:412)
	at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
	... 36 more
Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
	at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:410)
	... 39 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class . Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:94)
	at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseS
2014-01-16 16:27:19,921 INFO [utils.init.CommonContextListener] - <CommonContextListener init listener begin.>
tatementNode(XMLStatementBuilder.java:83)
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
	... 41 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:109)
	at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:115)
	at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:92)
	... 45 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
	at org.apache.ibatis.io.Resources.classForName(Resources.java:250)
	at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:105)
	... 47 more



xml配置如下:




错误点:

看到那个


resultType


了么,就是它惹的祸,这里把


resultType


改为



resultMap



就OK啦,重启tomcat,木有异常啦