https://blog.csdn.net/zhaomengxia123/article/details/98634945
文章中一.springboot+mybatis+maven+mysql+swagger结束之后
生成我所连数据库中的student,teacher,course三张表如图所示
此时我在测试类中编写如下测试
启动我本项目的启动类报错信息如下
我启动我刚才编写的单元测试报错信息如下
2019-09-02 14:25:36.848 WARN 19392 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testController': Unsatisfied dependency expressed through field 'studentService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentService': Unsatisfied dependency expressed through field 'studentMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.springboot_mybatis_module.springboot_mybatis_module.dao.StudentMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-09-02 14:25:36.857 INFO 19392 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-02 14:25:36.965 ERROR 19392 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field studentMapper in com.springboot_mybatis_module.springboot_mybatis_module.service.StudentService required a bean of type 'com.springboot_mybatis_module.springboot_mybatis_module.dao.StudentMapper' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.springboot_mybatis_module.springboot_mybatis_module.dao.StudentMapper' in your configuration.
2019-09-02 14:25:36.969 ERROR 19392 --- [ main] o.s.test.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@3427b02d] to prepare test instance [com.springboot_mybatis_module.springboot_mybatis_module.SpringbootMybatisMod