org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.SpringbootMybatisPulsDemo3ApplicationTests': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
原因是:没有扫描到mapper包
在主启动类上添加扫描mapper包的注解。
@MapperScan("com.dao")
即可