小白自学spring 先从springboot入手 spring只懂一点点 练习项目时一直报错 卡了一天了 球球大佬指导 人已经快疯了
这个是dao层
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookServiceImpl': 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)}
你跳过 Spring 的话,别人都不知道怎么跟你解释。建议该学的还得学完。
算了,直接给你一个视频地址
https://www.bilibili.com/video/BV1mY411b74B/
如何简单的搭建一个包含 mybatis-plus 框架的项目,并且如何编写单元测试。你的单元测试不是这么写的
1.BookDao 上面打上@Mapper注解还注入bean失败,猜测是mybatis的依赖出现问题,请你使用springboot starter的mybatis依赖,下面是例子
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.1</version>
</dependency>
```java
```
可以先尝试在mapper上再加上一个@Repository
注解
你在启动类上面加上@mapperScan扫描dao层的包路径
如果你用的mysql数据库,可以试试在配置文件中的datasouyce.url后面加上?serverTimezone=GMT%2B8 试试