出现如下错误:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.Springboot08SsmpApplicationTests': Unsatisfied dependency expressed through field 'bookDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.dao.BookDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
大意就是:注入为空,应该有一个bookDao对象(实际没有)
解决办法:在运行文件上加一句
@MapperScan("com.dao")
(也就是当前dao或mapper所在包)
运行测试类即可注入成功!!!
至于原因还没有搞明白,欢迎大家探讨