艾玛,增加个功能,改了下配置,结果异常狂抛,百思不得解啊,百度了下,从一个老兄那得到了正解,记录下,少走弯路。。
异常信息如下:
-
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
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,木有异常啦