Consider defining a bean of type ‘XXXX‘ in your configuration.

今天学习尚硅谷的SpringCloud时,发现支付模块无法启动,控制台输出下面的错误:

看起来可能是dao层没有被注入。

然后根据我已有的知识,我检查了注解@Mapper

@Mapper
public interface PaymentDao {
    public int create(Payment payment);
    public Payment getPaymentById(@Param("id") long id);
}

pom也添加了starter-web依赖:

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-web</artifactId>
</dependency>

然后不知道原因了,于是凭借死马当活马医的理念,试着在启动类添加了注解@ComponentScan,结果启动成功

@SpringBootApplication
@ComponentScan(basePackages = {"com.atguigu.springcloud.dao"})
public class PaymentMain8001 {
    public static void main(String[] args){

        SpringApplication.run(PaymentMain8001.class, args);
    }
}

我是跟着视频,一行代码,一行代码的照着敲的。视频里是没有写@ComponentScan的,但是视频里却能成功启动。难道我看的视频不完整?还是什么其他原因?哎,搞不懂。。。

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-12 15:34:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-12 15:34:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-12 15:34:04       87 阅读
  4. Python语言-面向对象

    2024-01-12 15:34:04       96 阅读

热门阅读

  1. python3.7conda安装opencv

    2024-01-12 15:34:04       59 阅读
  2. git命令

    git命令

    2024-01-12 15:34:04      52 阅读
  3. oracle 存储过程模板

    2024-01-12 15:34:04       52 阅读
  4. 青龙面板教程

    2024-01-12 15:34:04       87 阅读
  5. 【AI应用】HumanCenteredSensing

    2024-01-12 15:34:04       54 阅读