Springboot 中报错 Your ApplicationContext is unlikely to start due to a @ComponentScan

用springboot 写scala代码是最近做的一个项目,但是我启动的时候抛了一个错误,具体就是Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package

大概意思就是ApplicationContext 不能从一个组件的默认包启动

SpringBoot在写启动类的时候如果不使用@ComponentScan指明对象扫描范围,默认指扫描当前启动类所在的包里的对象,如果当前启动类没有包,则在启动时会报错Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package

我们需要新建一个包,然后把启动类放到新的包下面就可以了

比如我新建了一个controller包,然后把代码放到controller包下面,问题解决!

或者使用@ComponentScan注解

@SpringBootApplication
@ComponentScan(basePackageClasses=MytestApplication.class)
def  MytestApplication {}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值