请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

springboot测试时启动,报UnsatisfiedDependencyException

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.imooc.service.impl.ProductCategoryServiceImplTest’: Unsatisfied dependency expressed through field ‘categoryService’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.imooc.service.impl.ProductCategoryServiceImpl’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.imooc.service.impl.ProductCategoryServiceImpl’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

图片描述

![

正在回答 回答被采纳积分+3

插入代码

2回答

慕容8211654 2019-08-20 20:52:27

我也出现了这个问题,把sell包下的启动类移出去,放在com.imooc下就可以了。我也是创建项目就这样,可能是idea版本不一样导致的吧

0 回复 有任何疑惑可以回复我~
廖师兄 2019-08-01 23:56:10

不要按自己想法乱写。。。课程里没有教@SpringTest()里面这样写吧

0 回复 有任何疑惑可以回复我~
  • 提问者 慕后端0344139 #1
    廖老师,我哪写的springtest(),我是按照的你的视频的播放顺序敲的,最接近的你说的就是springboottest(),可是不加classes=xxx.class,就会报unable to find a @springbootconfiguration
    回复 有任何疑惑可以回复我~ 2019-08-02 08:38:38
  • 廖师兄 回复 提问者 慕后端0344139 #2
    可是不加classes=xxx.class,就会报unable to find a @springbootconfiguration,不用加的。
    你的项目下怎么没有SellApplication.java,仔细对比我的源码
    回复 有任何疑惑可以回复我~ 2019-08-05 17:35:01
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信