:No qualifying bean of type 'com.example.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}”
问题原因:建springboot工程选择的是3.3.1版本后pom文件中parent手动改为2.3.2版本(见前贴)
解决方案:pom文件中parent版本改回3.3.1版本
继续报错:
“Error:(6, 38) java: 无法访问org.springframework.stereotype.Repository
错误的类文件: /D:/WorkingSoftwareInstall/maven/scarepository/org/springframework/spring- context/6.0.10/spring-context-6.0.10.jar!/org/springframework/stereotype/Repository.class
类文件具有错误的版本 61.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。”
问题原因:pom中parent版本改回3.3.1版本后@Repository不兼容创建springboot时选择的jdk1.8
解决方案:pom中parent版本改回2.3.2版本后,手动修改mybatis相关依赖的3.0.3版本为如下
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.4</version> </dependency>