最近用SpringBoot写了一个项目,作为小程序的后台接口,开始的时候没有问题,当一系列的VO、service、impl、controller等方法写完以后,发现无法启动,报如下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field icbc in com.yundaotu.hebi.service.AppImpl required a bean of type 'com.wx.service.IcbcService' 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.wx.service.IcbcService' in your configuration.
上网查找原因说是找不到那个类,需要添加一个注解:
在springboot启动类上添加注解 @ComponentScan(basePackages = { "com.wx" }),添加之后但仍然没有解决;
于是经过各种仔细检查,发现是IcbcServiceImpl的接口实现类上没有添加@Service注解

添加之后 启动成功
本文记录了一位开发者在使用SpringBoot构建小程序后台接口时遇到的应用启动失败问题。在编写了一系列VO、service、impl、controller后,由于缺少@Service注解,导致IcbcServiceImpl接口实现类未被扫描到,从而引发错误。通过在启动类添加@ComponentScan注解尝试解决,但未奏效。最终,开发者发现并修复了IcbcServiceImpl上缺失的@Service注解,成功启动了应用。
6452





