在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"/>

有这两句后程序正常。

小结:物理上没有关系上的两个独立工程之间建立关系必须要有中间件作为桥梁,这样被服务方在注入服务方的服务时才会正常。

posted @ 2018-09-06 23:41  孤独的战斗笋  阅读(5695)  评论(0编辑  收藏  举报