Spring cloud多模块开发下Feign的使用,以及@FeignClient注入bean找不到异常解决


问题描述

SpringCloud使用Fegin调用其它模块的功能,会报找不到我们定义的Fegin bean的错误

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

Description:

Field eduCourseClient in com.qiuchuanze.eduorder.service.impl.TOrderServiceImpl required a bean of type 'com.qiuchuanze.client.EduCourseClient' 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.qiuchuanze.client.EduCourseClient' in your configuration.


解决方案:

出现这个问题,首先要确定在启动类上是否添加了@EnableFeignClients注解,并且需要配置上Feign客户端接口的包我这边自己的路径是
@EnableFeignClients(basePackages = "com.qiuchuanze.client")
加上搞定!

问题描述

关于SpringCloud Fegin可以调用别的模块的方法,但是调不了配置属性,如果要调用的模块中有特定的配置属性,还得把属性复制过来,比如没调过来就会报这样的错误

org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'constantPropertiesUtilUcenter': 
Injection of autowired dependencies failed;
 nested exception is java.lang.IllegalArgumentException:
  Could not resolve placeholder 'wx.open.app_id' in value "${wx.open.app_id}"
Caused by: java.lang.IllegalArgumentException: 
Could not resolve placeholder 'wx.open.app_id' in value "${wx.open.app_id}"

解决方案:

在调用的模块的配置文件中加入被调用的模块,搞定!

# 微信开放平台 appid
wx.open.app_id=****************
# 微信开放平台 appsecret
wx.open.app_secret=**********************************
# 微信开放平台 重定向url
wx.open.redirect_url=http://localhost:8160/api/ucenter/wx/callback

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值