Can I configure a @FeignClient url using a properties/yml file?

≯℡__Kan透↙ 提交于 2019-11-28 19:18:48

It can be done with a "serviceId" instead of a "url". E.g.

@FeignClient("foo")
interface Client { ... }

and

foo.ribbon.listOfServers: localhost:9000

e.g. see http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-ribbon-without-eureka for docs.

cody123

This can be done like this:

@FeignClient(name="fd-mobileapi-service",url="${fdmobile.ribbon.listOfServers}")

Where fdmobile.ribbon.listOfServers : value is a property in application.properties.

I have tested it and it is working.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!