Search code examples
spring-bootfeign

FeignClient service name configure through application.properties not working


I am trying configure service name for FeignClient from application.properties.

It works when I hardcode my service name like below.

@FeignClient("userdetail-service")

public interface UserServiceClient {
@RequestMapping(
            method= RequestMethod.GET,
            value = "/alluser/getmyuser)
    String getUserDetails();
    }

But same thing does not work when I try through application.properties

@FeignClient("${userservice.name}")

public interface UserServiceClient {
@RequestMapping(
            method= RequestMethod.GET,
            value = "/alluser/getmyuser)
    String getUserDetails();
    }

and in my application.properties i added below

userservice.name="userdetail-service"

I get below error when I start spring application

java.lang.IllegalStateException: Service id not legal hostname ("userdetail-service")

Solution

  • You don't need quotes in your application.properties file. Try

    userservice.name=userdetail-service