解决idea启动报错:Consider defining a bean of type ‘com.service.applicant.Applicant‘ in your configuration.

短命女 2024-03-31 14:27 137阅读 0赞

idea在启动时,报错:报错日志为

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. Parameter 0 of method setApplicant in webService.controller.RequestController required a bean of type 'com.service.applicant.Applicant' that could not be found.
  6. Action:
  7. Consider defining a bean of type 'com.service.applicant.Applicant' in your configuration.

解决方法

在启动类上面加上如下注解,添加的内容视具体是哪一个bean而定

  1. @SpringBootApplication
  2. // 添加没有扫描到的bean的路径
  3. @ComponentScan({
  4. "com.service"})
  5. // 如果引入的包不是本项目的,那么还需要再加一行扫描自己项目的bean
  6. @ComponentScan({
  7. "com.abc"})
  8. public class WebServiceApplication {
  9. // .....
  10. }

发表评论

表情:
评论列表 (有 0 条评论,137人围观)

还没有评论,来说两句吧...

相关阅读