Reputation: 456
I want to set the service name in @FeignClient from a properties file, like this:
@FeignClient("${service.users}")
and have the name set in application.yml
for example:
service.users: user-service
Where user-service
is the name by which the service is registered in Eureka.
I have tried and it does not work. It complains for invalid name.
Can something like this be done?
Upvotes: 3
Views: 4111
Reputation: 7543
i tried to use similar configuration:
@FeignClient(name = "${spring.application.name:optional.application.name}")
application.yml, bootstrap.yml:
spring:
application:
name: my-test-application
checking log after start
2016-05-24 16:11:00 [hystrix-my-test-application-1] INFO o.s.c.a.AnnotationConfigApplicationContext.prepareRefresh...
Also i had found in zookeeper active service
>ls /service/my-test-application
[8668663c-cce1-4181-94de-4ccaacefa7e3]
checked in debug mode client bean - it was created
HardCodedTarget(type=EventBusClient, name=fnma-cp-test, url=http://my-test-application)
So this configuration should work. My suggestions are:
please create next file structure:
application.yml
META-INF
|-additional-spring-configuration-metadata.json
where additional-spring-configuration-metadata.json should have something like this
{
"properties": [
{
"name": "service.users",
"type": "java.lang.String",
"description": "Description for service.users.",
"defaultValue": "Some_Value"
}
]
}
Anyway if any problems with additional-spring-configuration-metadata.json you can find explanations here: enter link description here
Upvotes: 1
Reputation: 2080
This can be done like this.
@FeignClient(name="fd-mobileapi-service",url="${fdmobile.ribbon.listOfServers}")
fdmobile.ribbon.listOfServers : value =>> this will be a property in application.properties.
Upvotes: 1