问题描述
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