转载:https://blog.csdn.net/qq_38537709/article/details/104750598

问题描述
A模块的controller类依赖B模块的Service类,项目运行时报错

Parameter 0 of constructor in com.example.multimodule.application.DemoApplication required a bean of type 'com.example.multiservice.MyService' that could not be found.
  • 1
A模块 controller类包名 B模块 service类包名 A模块包扫描路径 依赖
com.example.multimodule.application com.example.multimodule.service com.example.multimodule 成功
com.example.multimodule.application com.example.service com.example.multimodule 失败
com.example.multimodule.application com.example.service com.example 成功

问题解决办法

  1. 扩大包扫描路径范围
  2. 将依赖不成功的包名添加到包扫描路径下

本质上是一个包扫描的问题。

相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2021-07-25
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-15
猜你喜欢
  • 2022-12-23
  • 2021-12-14
  • 2021-05-11
  • 2021-09-03
  • 2022-12-23
相关资源
相似解决方案