启动项目报错

2018-02-26 17:09:51,535 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testTreeDao' defined in file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/com/thinkgem/jeesite/test/dao/TestTreeDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/spring-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/mappings/modules/sys/RoleDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 14; The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at com.thinkgem.jeesite.modules.sys.listener.WebContextListener.initWebApplicationContext(WebContextListener.java:16)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/spring-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/mappings/modules/sys/RoleDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 14; The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1572)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
... 25 more
Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource:
'file [/Users/jds/Documents/eclipse/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeesite/WEB-INF/classes/mappings/modules/sys/RoleDao.xml]';
nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.
Cause: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 14; The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:522)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
... 32 more
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 14; The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:256)
at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:125)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:86)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:515)
... 35 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 14; The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:254)
... 38 more

重点在上面代码中的标红出,指出了 RoleDao.xml的报错

The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".

以上报错的意思是  元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminator?)"

解决方法:

将resultMap 中各元素的顺序修改为和错误信息中属性出现的顺序( constructor ,  id   result  association .....)一致

例如

之前的xml文件中代码

  <resultMap id="roleResult" type="Role">
2 <id property="id" column="id" />
3 <association property="office" javaType="Office">
4 <id property="id" column="office.id" />
5 <id property="name" column="office.name" />
6 </association>
7 <result property="name" column="name" />
8 <result property="enname" column="enname" />
9 <result property="roleType" column="roleType" />
10 <result property="dataScope" column="dataScope" />
11 <result property="remarks" column="remarks" />
12 <result property="useable" column="useable" />
13 <result property="sysData" column="sysData" />

<collection property="menuList" ofType="Menu">
<id property="id" column="menuList.id" />
</collection>
<collection property="officeList" ofType="Office">
<id property="id" column="officeList.id" />
</collection>
</resultMap>

解决后xml文件中的代码

 <resultMap id="roleResult" type="Role">
2 <id property="id" column="id" />
3 <result property="name" column="name" />
4 <result property="enname" column="enname" />
5 <result property="roleType" column="roleType" />
6 <result property="dataScope" column="dataScope" />
7 <result property="remarks" column="remarks" />
8 <result property="useable" column="useable" />
9 <result property="sysData" column="sysData" />
10 <association property="office" javaType="Office">
11 <id property="id" column="office.id" />
12 <id property="name" column="office.name" />
13 </association>
<collection property="menuList" ofType="Menu">
<id property="id" column="menuList.id" />
</collection>
<collection property="officeList" ofType="Office">
<id property="id" column="officeList.id" />
</collection>
</resultMap>

mybatis项目启动报错 The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collection*,discriminator?)".的更多相关文章

  1. The content of element type "resultMap" must match "(constructor?,id*,result*,association*,collectio

    The content of element type "resultMap" must match "(constructor?,id*,result*,associa ...

  2. mybatis配置文件,注意标签配置顺序。否则报错The content of element type "configuration" must match "(properties?,settings?,...怎么解决

    感谢原作者http://www.cnblogs.com/zhoumingming/p/5417014.html 注意每个标签必须按照顺序写,不然就会提示错误 顺序是 <?xml version= ...

  3. taglib报错The content of element type "taglib" must match "(tlib-version,...)

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE taglib PUBLIC "-// ...

  4. 解决 Mybatis 元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminat

    在配置 mybatis mapper.xml文件时, 一不小心就会报如下类似的异常: Caused by: org.springframework.beans.factory.BeanCreation ...

  5. The content of element type "resultMap" must match ...

    mybatis中的mapper文件错误 ①错误原因: <resultMap>标签中需要按照一下顺序编写: <id> <result> <association ...

  6. 错误Mybatis 元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminat

    今天算是见识了什么事顺序的重要性. 在使用mybatis时由于联合了其他的表,用到了resultMap,之后外加association这一项.可是在替换对应字段的位置上加上association总是报 ...

  7. spring+mybatis项目启动报错Initializing Spring root WebApplicationContext

    这个问题很怪异,各种各样的情况都会导致这个问题的出现,主要是由于sping加载读取配置文件的时候出了问题.我在处理mybatis的时候出现了这个问题,后来排查发现,在mybatis的配置文件中如果有大 ...

  8. 写hibernate.cfg.xml时报错The content of element type "property" must match "(meta*,(column|formula)*,type?)".

    原配置文件是这样的 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-ma ...

  9. Mybatis 元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminat

    <resultMap id="BaseResultMap" type="com.youotech.tl_cons_credit_rating.entity.TL_C ...

随机推荐

  1. 使用Dockerfile文件制作centos6.8基础镜像,基于centos基础镜像的ssh远程登录镜像,jdk1.8镜像,tomcat镜像,elasticsearch镜像等等

    一.首先制作一个centos6.8的裸机镜像 创建一个干净的目录: [root@docker centos6.]# ls c68-docker.tar.xz Dockerfile Dockerfile ...

  2. 通过JS模拟select表单,达到美化效果[demo][转]

    转自: http://www.cnblogs.com/dreamback/p/SelectorJS.html 通过JS模拟select表单,达到美化效果 Demo ------------------ ...

  3. CCCC L2-008. 最长对称子串

    https://www.patest.cn/contests/gplt/L2-008 题解:想法是扫一遍string,将每一个s[i]作为对称轴,写一个判定函数:不断向两边延伸直到不是回文串为止. ...

  4. Oracle性能优化之普通用户使用dbms_xplan包需要有的权限

    普通用户使用dbms_xplan包查看执行计划需要对v$sql.v$sql_plan.v$session及v$sql_plan_statistics_all这四个视图同时具有select权限. 如果普 ...

  5. JS继承封装

    <script> var extend = function (subClass, superClass) { //1.继承类的中间类 var Tmp = function() {}; / ...

  6. struts2 错误:Dispatcher initialization failed java.lang.RuntimeException

    严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationTargetE ...

  7. requests库的小技巧

    #coding:utf-8 import requests # url = 'http://www.baidu.com' # response = requests.get(url) # print ...

  8. appstore加速审核通道

    申请入口:https://developer.apple.com/contact/app-store/?topic=expedite

  9. java获取屏幕密度

    方法1: float xdpi = getResources().getDisplayMetrics().widthPixels;float ydpi = getResources().getDisp ...

  10. SQL Server 安装后改动计算机名带来的问题以及解决方法

    USE master GO DECLARE @serverproperty_servername varchar(100), @servername varchar(100) --取得Windows ...