Eureka Client – can’t autowire client (spring says there are 2 beans defined)

I have an application that is a eureka discovery client.

It registers with my Eureka server just fine.

Sadly when I try to autowire the EurekaClient in any @Component or @Service class to fetch registry instance details, I’m told that I can’t autowire as there are 2 bean definitions:

enter image description here

I don’t know what is causing this. I have the following dependencies in my pom.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
    <exclusions>
        <exclusion>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jersey</artifactId>
</dependency>`

The exclusion in the first dependency is due to conflicts with the second.

My app is a discovery enabled app through the following configuration class:

@Configuration
@EnableDiscoveryClient
public class EurekaDiscoveryConfiguration {
}

I really don’t understand why it thinks there are 2 beans matching that description.

FWIW, strangely enough I can autowire it in classes that are not annotated with @Component or @Service… and they work – i’ve managed to get them returning instance info correctly.

I have a feeling, and i’ve read a bit around it, that using jersey 2.0 for my services interferes with eureka. I might just swap to consul……

Many thanks in advance for any advice.