Error creating bean with name ‘XXXX‘ defined in file

最近做springboot +springcloud项目时候遇见了好几次这个错误,百度的方法都不管用,最后检查发现了原因,供大家参考
The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
错误如下:
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘fhxInternalClaimService’ defined in file [D:\reins-internal-excess-backend\target\classes\com\pdfc\platform\application\service\fhxinternal\FhxInternalClaimService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fhxInternalClaimDomainService' defined in file [D:\reins-internal-excess-backend\target\classes\com\pdfc\platform\domain\fhxinternalclaim\service\FhxInternalClaimDomainService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fhxInternalClaimDao' defined in file [D:\reins-internal-excess-backend\target\classes\com\pdfc\platform\domain\fhxinternalclaim\repository\facade\FhxInternalClaimDao.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 [D:\reins-internal-excess-backend\target\classes\mapper\custom\fhxinternaltreaty\FhxInternalTreatyDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\reins-internal-excess-backend\target\classes\mapper\custom\fhxinternaltreaty\FhxInternalTreatyDao.xml]'. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.pdfc.platform.domain.fhxinternaltreaty.repository.facade.FhxInternalTreatyDao.selectTreatyInfoAndFzacc. please check file [D:\reins-internal-excess-backend\target\classes\mapper\custom\fhxinternaltreaty\FhxInternalTreatyDao.xml] and file [D:\reins-internal-excess-backend\target\classes\mapper\custom\fhxinternaltreaty\FhxInternalTreatyDao.xml]

The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer C o n d i t i o n O b j e c t . a w a i t N a n o s ( A b s t r a c t Q u e u e d S y n c h r o n i z e r . j a v a : 2078 ) j a v a . u t i l . c o n c u r r e n t . S c h e d u l e d T h r e a d P o o l E x e c u t o r ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078) java.util.concurrent.ScheduledThreadPoolExecutor ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)java.util.concurrent.ScheduledThreadPoolExecutorDelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor D e l a y e d W o r k Q u e u e . t a k e ( S c h e d u l e d T h r e a d P o o l E x e c u t o r . j a v a : 809 ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . g e t T a s k ( T h r e a d P o o l E x e c u t o r . j a v a : 1067 ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r . r u n W o r k e r ( T h r e a d P o o l E x e c u t o r . j a v a : 1127 ) j a v a . u t i l . c o n c u r r e n t . T h r e a d P o o l E x e c u t o r DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127) java.util.concurrent.ThreadPoolExecutor DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)java.util.concurrent.ThreadPoolExecutorWorker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:744)

百度得到的问题和解决方案如下几种:

  1. 注解用错
    检查类的注解是不是用错了,或者拼错了

  2. 配置文件错误
    xml中应该配置的引用包,相应的配置没有配置

  3. jar包问题
    引用的jar包冲突,或者没有引用相关的jar包

我的原因有好几种,
第一种:启功配置没有配置参数
如下图的Vm options
在这里插入图片描述
第二种:
Mybatis的Mapper里面sql语法有错误,id标志不唯一
我的原因就是写了两个id相同的sql
例如id重复

第三种:
项目打包成功后,没有重启consul

本菜鸟自己创建的交流群,欢迎大佬和java学习者加入扣扣群:344635699

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值