在用Spring Boot整合Mybatis时,遇到了一个这样的报错
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
但是在后台还是可以运行查看到json字符串
IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示
但是对于这个报错,看上去还是感觉不满意,于是查找资料之后,找到了下面几种解决办法

(1)在注解上加上:required = fales

IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示

(2)使用 @Resource 替换 @Autowired

IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示

(3)在 MyBatis 接口上加上 @Repository 注解

IDEA在写Mybatis时遇到了Could not autowire. No beans of 'xxxx' type found 的错误提示

(4)使用 Lombok,@RequireArgsContructor

(5)降低 Autowired 检测的级别,将 Severity 的级别由之前的 error 改成 warning 或其它可以忽略的级别。

(6)安装 MyBatis 插件

(7)构造器注入

相关文章:

  • 2021-10-12
  • 2021-07-28
  • 2021-08-20
猜你喜欢
  • 2021-07-09
  • 2021-08-14
  • 2022-12-23
  • 2021-05-31
  • 2021-10-02
  • 2021-12-16
相关资源
相似解决方案