ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

元素类型为 “resultMap“ 的内容必须匹配 “(constructor?,id*,result*,association*,collection*,discriminator?)“

2021-01-19 13:00:28  阅读:183  来源: 互联网

标签:13 4.3 springframework collection beans resultMap RELEASE org result


一、问题

新搭建的springboot项目,在项目启动的时候报错

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testImpl': Unsatisfied dependency expressed through field 'ciclaimplatformdwService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testImpl': Unsatisfied dependency expressed through field 'testDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ciclaimplatformdwDao' defined in file [E:\test\target\classes\ins\claim\business\middle\dao\testwDao.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 [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\test\target\classes\mapper\base\middle\test02Dao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 45; columnNumber: 14; 元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminator?)"。
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
	at ins.claim.TestApplication.main(TestApplication.java:29) [classes/:na]

报错信息很多,只复制最上面的报错信息

二、问题原因分析

查找了很多网上资料大不分都是说resultMap中constructor?,id*,result*,association*,collection*,discriminator这些标签书写顺序的问题,跟我遇到的实际情况不符

我的resultMap中只有id和result两个标签

我遇到问题的主要原因是在于问题原因的定位,将报错文件定位错了,所以一直没有找到问题所在

错误信息首行里面记录的报错信息很长,报错信息最前面的文件testImpl文件是自己写的,实际的报错文件DatachangeListForBiBaseDao.xml不是自己写的,忽视了,默认以为是testImpl对应的xml文件出现错了,结果查找了很多遍没有发现问题所在,而实际是因为DatachangeListForBiBaseDao.xml这个文件中的ID生成到了resultMap最下方才导致的

Error creating bean with name 'testImpl': Unsatisfied dependency expressed through field 'ciclaimplatformdwService'; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'testImpl': 
Unsatisfied dependency expressed through field 'testDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException:
 Error creating bean with name 'ciclaimplatformdwDao' defined in file [E:\test\target\classes\ins\claim\business\middle\dao\testDao.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 
[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; 
nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: '
file [E:\test\target\classes\mapper\base\middle\DatachangeListForBiBaseDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: 
Error creating document 
instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 45; columnNumber: 14; 元素类型为 "resultMap" 的内容必须匹配 "
(constructor?,id*,result*,association*,collection*,discriminator?)"。

三、解决

将DatachangeListForBiBaseDao.xml文件中resultMap中的id标签放到最上方

四、经验

报错信息及时很长,也需要认真的分析一下,不然一开始问题源头就搞错了,后面怎么查找也是白搭

 

 

标签:13,4.3,springframework,collection,beans,resultMap,RELEASE,org,result
来源: https://blog.csdn.net/qq_39539346/article/details/112811544

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有