Skip to content

Confusing Error: No Feign Client for loadBalancing defined. #517

Closed
@brimworks

Description

@brimworks

Describe the bug
A common scenario is to define a @FeignClient as such:

    @FeignClient(name = "myfeignclient", url = "${my.url}")
    public interface TestFeignClient {
        @GetMapping(value = "/test")
        public Map<String, String> test();
    }

Notice the url is resolved from a property. It also isn't to uncommon to have a configuration which resolves the property to the value of an environment variable:

my:
    url: ${MY_URL}

Now if MY_URL is defined as the empty string, you get this error message:

No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

Which is very misleading... when the real issue is that no url was defined. I'd suggest changing this line of code:

To be:

if (Objects.isNull(url)) {

It would definitely have helped me out. To work around this issue, I've been adding custom conditional annotations which disable my feign client if the url property is missing or null (since @ConditionalOnProperty will trigger even if it is an empty string).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions