开发-后端-错误记录-1
敲代码的时候 遇到下面这个错误!
Field userNameDao in com.mangesystem.Service.impl.userNameServiceImpl required a bean of type 'com.mangesystem.Dao.userNameDao' 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.mangesystem.Dao.userNameDao' in your configuration.
尝试了(24.8.4)网上流传的正常的解决方式(启动类位置放置/加MapperScan/)都不行 。
最后知道是Springboot版本和mabatis启动依赖版本不匹配导致的。我使用的版本
<!-- spring-boot起步依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.2.7</version>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
从结果上看这个版本搭配是没问题的