解决,springboot项目,子模块依赖问题

转载: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.applicationcom.example.multimodule.servicecom.example.multimodule成功
com.example.multimodule.applicationcom.example.servicecom.example.multimodule失败
com.example.multimodule.applicationcom.example.servicecom.example成功

问题解决办法

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

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

原文地址:https://www.cnblogs.com/donglaotao/p/14353581.html