springboot测试时启动,报UnsatisfiedDependencyException

来源:4-1 买家类目-dao(上)

慕后端0344139

2019-08-01

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)}

图片描述

![

写回答

2回答

慕容8211654

2019-08-20

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

0
0

廖师兄

2019-08-01

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

0
2
廖师兄
回复
慕后端0344139
可是不加classes=xxx.class,就会报unable to find a @springbootconfiguration,不用加的。 你的项目下怎么没有SellApplication.java,仔细对比我的源码
2019-08-05
共2条回复

Spring Boot双版本(1.5/2.1) 打造企业级微信点餐系统

从0到1开发中小型企业级Java应用,并学会迭代重构技巧

6410 学习 · 5247 问题

查看课程