UnsatisfiedDependencyException: Error creating bean with name ‘TUserService‘: Unsatisfied dependency

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’: Injection of autowired dependencies failed; nested exception is java.lang.NoSuchFieldError: filters
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:380) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean 0 ( A b s t r a c t B e a n F a c t o r y . j a v a : 320 )   [ s p r i n g − b e a n s − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t S i n g l e t o n B e a n R e g i s t r y . g e t S i n g l e t o n ( D e f a u l t S i n g l e t o n B e a n R e g i s t r y . j a v a : 222 )   [ s p r i n g − b e a n s − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . d o G e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 318 )   [ s p r i n g − b e a n s − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . g e t B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 199 )   [ s p r i n g − b e a n s − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . p r e I n s t a n t i a t e S i n g l e t o n s ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 843 )   [ s p r i n g − b e a n s − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . f i n i s h B e a n F a c t o r y I n i t i a l i z a t i o n ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 877 )   [ s p r i n g − c o n t e x t − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . c o n t e x t . s u p p o r t . A b s t r a c t A p p l i c a t i o n C o n t e x t . r e f r e s h ( A b s t r a c t A p p l i c a t i o n C o n t e x t . j a v a : 549 )   [ s p r i n g − c o n t e x t − 5.1.7. R E L E A S E . j a r : 5.1.7. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . w e b . s e r v l e t . c o n t e x t . S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . r e f r e s h ( S e r v l e t W e b S e r v e r A p p l i c a t i o n C o n t e x t . j a v a : 142 )   [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h ( S p r i n g A p p l i c a t i o n . j a v a : 775 ) [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r e f r e s h C o n t e x t ( S p r i n g A p p l i c a t i o n . j a v a : 397 ) [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 316 ) [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 1260 ) [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . S p r i n g A p p l i c a t i o n . r u n ( S p r i n g A p p l i c a t i o n . j a v a : 1248 ) [ s p r i n g − b o o t − 2.1.5. R E L E A S E . j a r : 2.1.5. R E L E A S E ] a t c o m . r e f i . d e m o . c o n t r o l l e r . W e c a h t D e m o A p p l i c a t i o n . m a i n ( W e c a h t D e m o A p p l i c a t i o n . j a v a : 13 ) [ c l a s s e s / : n a ] C a u s e d b y : j a v a . l a n g . N o S u c h F i e l d E r r o r : f i l t e r s a t c o m . a l i b a b a . d r u i d . s p r i n g . b o o t . a u t o c o n f i g u r e . D r u i d D a t a S o u r c e W r a p p e r . a d d S t a t F i l t e r ( D r u i d D a t a S o u r c e W r a p p e r . j a v a : 61 )   [ d r u i d − s p r i n g − b o o t − s t a r t e r − 1.1.9. j a r : n a ] a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e 0 ( N a t i v e M e t h o d )   [ n a : n a ] a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . N a t i v e M e t h o d A c c e s s o r I m p l . i n v o k e ( N a t i v e M e t h o d A c c e s s o r I m p l . j a v a : 62 )   [ n a : n a ] a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . D e l e g a t i n g M e t h o d A c c e s s o r I m p l . i n v o k e ( D e l e g a t i n g M e t h o d A c c e s s o r I m p l . j a v a : 43 )   [ n a : n a ] a t j a v a . b a s e / j a v a . l a n g . r e f l e c t . M e t h o d . i n v o k e ( M e t h o d . j a v a : 564 )   [ n a : n a ] a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . a n n o t a t i o n . A u t o w i r e d A n n o t a t i o n B e a n P o s t P r o c e s s o r 0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.5.RELEASE.jar:2.1.5.RELEASE] at com.refi.demo.controller.WecahtDemoApplication.main(WecahtDemoApplication.java:13) [classes/:na] Caused by: java.lang.NoSuchFieldError: filters at com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper.addStatFilter(DruidDataSourceWrapper.java:61) ~[druid-spring-boot-starter-1.1.9.jar:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor 0(AbstractBeanFactory.java:320) [springbeans5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [springbeans5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) [springbeans5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [springbeans5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843) [springbeans5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) [springcontext5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) [springcontext5.1.7.RELEASE.jar:5.1.7.RELEASE]atorg.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) [springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atorg.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)[springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atorg.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)[springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:316)[springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1260)[springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atorg.springframework.boot.SpringApplication.run(SpringApplication.java:1248)[springboot2.1.5.RELEASE.jar:2.1.5.RELEASE]atcom.refi.demo.controller.WecahtDemoApplication.main(WecahtDemoApplication.java:13)[classes/:na]Causedby:java.lang.NoSuchFieldError:filtersatcom.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper.addStatFilter(DruidDataSourceWrapper.java:61) [druidspringbootstarter1.1.9.jar:na]atjava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod) [na:na]atjava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [na:na]atjava.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [na:na]atjava.base/java.lang.reflect.Method.invoke(Method.java:564) [na:na]atorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:708) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
… 17 common frames omitted

似乎为工程目录问题,com文件夹下直接放项目文件扫描不到,在com下在嵌套两个文件夹解决问题,如图:

在这里插入图片描述
记录一下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: "UnsatisfiedDependencyException" 是在 Spring Framework 中常见的错误之一, 它表示在创建 bean 时存在依赖关系错误. 一般是因为缺少某个必需的依赖或依赖关系配置错误导致的. 建议检查配置文件以及相关的类, 确保所有依赖都已正确配置. ### 回答2: unsatisfieddependencyexception(无法满足的依赖项异常)是Spring框架中常见的异常。当我们在初始化bean的时候,如果发现其依赖的其他bean没有被成功创建,就会抛出这个异常。 通常,出现这个异常的原因有三种情况: 1.依赖的bean没有被成功创建 这种情况常见的原因是bean的配置出现了错误,例如,在一个bean中引用了另一个bean,但是另一个bean的名称拼写错误,或者它在容器中根本不存在。在这种情况下,我们需要检查容器中所有引用的bean,确保它们都已经正确创建。 2.依赖项存在冲突 Spring允许我们在多个bean之间指定依赖关系,但是如果出现了依赖项存在冲突的情况,就会抛出unsatisfieddependencyexception异常。例如,在两个bean中都指定了相互依赖的另一个bean,就会出现冲突。在这种情况下,我们需要仔细检查bean之间的关系,并确保它们没有重复的依赖项。 3.依赖项的类型无法匹配 最后一个常见的原因是依赖项的类型不一致。例如,在一个bean中注入了一个List类型的依赖项,但是在容器中创建的bean实际上是一个Set类型的对象。在这种情况下,我们需要检查依赖项的类型,并确保它们在bean的配置中设定正确。 总之,unsatisfieddependencyexception异常通常是由于bean配置出现了错误或者容器中存在依赖项冲突或者类型不匹配的情况。在出现这个异常时,我们需要仔细检查bean的配置和依赖关系,并找出其中的问题,确保所有依赖项被正确创建。 ### 回答3: unsatisfieddependencyexceptionSpring 框架中的一个异常,通常出现在依赖注入(dependency injection)这一阶段。其错误信息是 Error creating bean with name,即在创建 bean 时出现了错误。这种异常的意思是在 Spring 依赖注入时,发现了一些依赖无法满足,无法将 bean 实例化。 在更具体的情况下,一个 bean 通常需要依赖于其他的 bean,在启动 Spring 应用程序时,Spring 会尝试为每个 bean 创建一个实例,并注入所需的依赖关系。如果 Spring 无法为某个 bean 创建实例,就会出现 unsatisfieddependencyexception 异常,这通常是由于以下原因引起的。 1. 未定义 Bean:bean 可能不存在,或者没有在 Spring 上下文中注册。这个问题可以通过在 Spring 的配置文件中添加 bean 来解决。 2. 循环依赖:如果两个或多个 bean 相互依赖,可能导致无法将它们实例化,从而引发 unsatisfieddependencyexception 异常。 3. 依赖项类型不匹配:当依赖项的类型与 Spring 确定的类型不匹配时,也可能导致无法注入,从而引发这种类型的异常。 4. 歧义依赖:当多个 bean 满足相同依赖关系时,Spring 无法确定要注入哪个 bean,这也会导致 unsatisfieddependencyexception 异常。 为了避免 unsatisfieddependencyexception 异常,我们应该在编写 Spring 配置文件时非常小心,确保所有 bean 注册,并且它们之间的依赖关系正确设置。同时,也要确保所有的依赖项类型是正确的,以及避免循环依赖和歧义依赖的问题。如果遇到这种异常,则需要仔细检查配置文件中的 bean 定义,以找出问题所在,并进行相应的修复。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zyss13

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值