【Springboot启动报错】xxController required a bean of type 'xxx.XXService' that could not be found.

问题描述

Description:

Field authorService in com.luck.graduate.controller.AuthorController required a bean of type 'com.luck.graduate.service.AuthorService' 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.luck.graduate.service.AuthorService' in your configuration.

在配置springboot环境时出现问题,自己新建的springboot项目配置和示例项目配置近乎相同,但自己的项目启动时就会报错,无法扫描到service包的@service注解,还得在Application启动类中添加@ComponentScan注解扫描service包。

(以后埋坑,了解为什么同样的配置文件,启动会出现不同的结果)

@SpringBootApplication
@ComponentScan(basePackages = {"com.xxx.xxx.service"})
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

参考链接:https://www.cnblogs.com/nananana/p/9333917.html

文中提到的方法①实测不行,不知道是我的配置有问题还是怎么的。

找到问题了,springboot启动类扫描其所在类及所有所在类子类下的文件是没问题的,是我当时service实现类配置出错,忘记继承接口类了qaq,真渔。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值