张小驰出没 张小驰出没
首页
  • Spring合集
  • SpringMVC合集
  • Mybatis合集
  • Spring Boot合集
  • Mybatis-plus合集
  • Spring Security合集
  • Vue合集
  • Redis合集
  • RabbitMQ合集
  • 数据结构

    • 数据结构
  • 算法解析

    • 日常算法
    • 剑指Offer
    • LeetCode
  • 技术与Bug

    • 技术文档
    • Bug解决方法
  • 个人博客

    • Hexo博客搭建
  • 我的项目
  • 我的面试
  • 分类
  • 标签
  • 归档
友链
关于
Hexo
GitHub

MoYu

何德何能,何其荣幸
首页
  • Spring合集
  • SpringMVC合集
  • Mybatis合集
  • Spring Boot合集
  • Mybatis-plus合集
  • Spring Security合集
  • Vue合集
  • Redis合集
  • RabbitMQ合集
  • 数据结构

    • 数据结构
  • 算法解析

    • 日常算法
    • 剑指Offer
    • LeetCode
  • 技术与Bug

    • 技术文档
    • Bug解决方法
  • 个人博客

    • Hexo博客搭建
  • 我的项目
  • 我的面试
  • 分类
  • 标签
  • 归档
友链
关于
Hexo
GitHub
  • springmvc字符中文乱码问题
  • 2字节的UTF-8序列的字节2无效解决方案
  • source is null for getProperty(null, "name")
  • 使用yum出现Loaded plugins:fastestmirror
  • FastDFS依赖无法导入
  • Could not autowire. No beans of 'xxx' type found
    • 遇到的问题
    • 解决方法
  • 《Bug解决》笔记
MoYu
2021-06-20

Could not autowire. No beans of 'xxx' type found

# Could not autowire. No beans of 'xxx' type found

如果是Spring Boot 项目中 Mapper 文件注入出现报错,可以尝试启动,如果可以正常启动的话,是不会影响的。

首先,检查三点

  1. 导入类是不是导入错了
  2. 依赖是不是导入错了
  3. 引入的类是不是对应依赖的

检查完毕,如果还是出现这样的问题,参考以下解决方法:

# 遇到的问题

Could not autowire. No beans of 'xxx' type found

这是我是在使用 WebSocket 的时候,引入 SimpMessagingTemplate 类,出现这个问题:

1

如果启动的话:

2

# 解决方法

1.启动类,加入启动注解 @SpringBootApplication

@SpringBootApplication
public class CloudApplication {
    public static void main(String[] args) {
        SpringApplication.run(CloudApplication.class,args);
    }
}
1
2
3
4
5
6

2.将启动类,移动到一个包下,不要放在根目录

3

这是我是新建的一个 start 包,启动类移入其中,就可以注入了

请大家一定注意:

大部分的无法注入问题,都是因为 依赖导入错误、引入错误 或者 直接写错了类 ,一定先排除这些可能

#Bug
上次更新: 2021/06/20, 09:51:53
FastDFS依赖无法导入

← FastDFS依赖无法导入

最近更新
01
链表
01-25
02
约瑟夫问题
01-25
03
快慢指针
01-25
更多文章>
Theme by Vdoing | Copyright © 2021-2022 MoYu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式