在Controller注入Service報錯的解決方法


Error creating bean with name 'loginController': Injection of autowired dependencies failed

以上為報錯信息,意思是創建bean loginController出錯: 注入失敗

dubbo的配置沒有寫所導致,在springmvc.xml加入下句后正常:
<dubbo:reference interface="cn.jhxcom.sso.service.LoginService" id="loginService" />

另外在service端的配置文件還要暴露服務,如下句:
<dubbo:service interface="cn.jhxcom.sso.service.LoginService" ref="loginServiceImpl" timeout="600000"/>

有這兩句后程序正常。

小結:物理上沒有關系上的兩個獨立工程之間建立關系必須要有中間件作為橋梁,這樣被服務方在注入服務方的服務時才會正常。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM