解決,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