mapper无法注入的问题

╰半橙微兮° 2023-10-04 11:31 93阅读 0赞

SpringBoot整合Mybatis,mapper无法注入

  1. Description:
  2. Field sysUserMapper in com.wzugx.mxbbx.serviceimpl.UserServiceImpl required a bean of type 'com.wzugx.mxbbx.mapper.SysUserMapper' that could not be found.
  3. Action:
  4. Consider defining a bean of type 'com.wzugx.mxbbx.mapper.SysUserMapper' in your configuration.

排除方法:
1、检查dao层的接口类是不是没有加@mapper注解
2、检查pom.xml的jar包依赖

然后你发现都没有错,注解加了,pom也有,就是下面的内容,复制过来了好几遍。

  1. <dependency>
  2. <groupId>org.mybatis</groupId>
  3. <artifactId>mybatis</artifactId>
  4. <version>3.5.1</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.mybatis</groupId>
  8. <artifactId>mybatis-spring</artifactId>
  9. <version>2.0.1</version>
  10. </dependency>

但是实际上就是依赖的问题,应该是下面的依赖

  1. <!--Mybatis-->
  2. <dependency>
  3. <groupId>org.mybatis.spring.boot</groupId>
  4. <artifactId>mybatis-spring-boot-starter</artifactId>
  5. <version>1.3.1</version>
  6. </dependency>

发表评论

表情:
评论列表 (有 0 条评论,93人围观)

还没有评论,来说两句吧...

相关阅读