解决:在微服务中一个服务访问另一个服务的类或方法出现的问题

我的需求:

我需要在用户模块使用公共模块的service和mapper和实体类,出现以下错误

springboot启动错误如下:

报错结果:需要一个类型为“com.buba.yka.mapper.salesmanMapper”的bean,但找不到该bean


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-07-02 21:00:53.940 ERROR 10300 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field salesmanMapper in com.business.yka.controller.BusinessController required a bean of type 'com.buba.yka.mapper.SalesmanMapper' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.buba.yka.mapper.SalesmanMapper' in your configuration.


Process finished with exit code 1

 解决问题:

business-server服务和common服务的包名不一致
所以在business-server服务中访问com.buba.yka.mapper.SalesmanMapper是访问不到的
需要两个服务的包名一致就可成功访问到
修改后

  

 重新启动,即可启动成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值