解决,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.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. 将依赖不成功的包名添加到包扫描路径下

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM