简体   繁体   中英

Feign Client, Spring Boot Application, and rx/Observable Class Not Found Error

Some background: I have built two Spring Boot applications that are designed to be microservices. The first application (schedule provision) is a RESTful service that provides data for the other application (schedule checker). Therefore, there is a simple producer-consumer relationship between the two services.

After following the Spring tutorials for setting up microservice discovery using Eureka , I have a Eureka service registry that can be successfully stood up and the schedule provision and schedule checker services successfully register themselves with the Eureka service registry (validated by checking the landing page for the Eureka service).

I have now attempted to set-up microservice communication using Feign Client , ie I defined a Feign Client interface in the schedule checker service which should enable this service to contact the schedule provision service through Eureka end-point resolution, and consume data from the schedule provision service. However, after starting the Eureka discovery service and schedule provision services as Spring Boot applications, I keep receiving the following error when attempting to run the schedule checker service as a Spring boot application:

java.lang.ClassNotFoundException: rx.Observable

This is the root cause of an error chain that reads from top to bottom as:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleCheckerController': Unsatisfied dependency expressed through field 'scheduleRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleRepositoryImpl': Unsatisfied dependency expressed through field 'scheduleService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleServiceImpl': Unsatisfied dependency expressed through field 'scheduleDatabaseClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.greensill.emailarrivalmonitoring.client.ScheduleDatabaseFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: rx/Observable
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1225) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:552) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE]
at com.greensill.emailarrivalmonitoring.EmailArrivalMonitoringApplication.main(EmailArrivalMonitoringApplication.java:18) [classes/:na]

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleRepositoryImpl': Unsatisfied dependency expressed through field 'scheduleService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleServiceImpl': Unsatisfied dependency expressed through field 'scheduleDatabaseClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.greensill.emailarrivalmonitoring.client.ScheduleDatabaseFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: rx/Observable
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1225) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:552) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 19 common frames omitted

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleServiceImpl': Unsatisfied dependency expressed through field 'scheduleDatabaseClient'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.greensill.emailarrivalmonitoring.client.ScheduleDatabaseFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: rx/Observable
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1225) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:552) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1136) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 32 common frames omitted

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.greensill.emailarrivalmonitoring.client.ScheduleDatabaseFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.NoClassDefFoundError: rx/Observable
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1626) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1297) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1263) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1099) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 45 common frames omitted

Caused by: java.lang.NoClassDefFoundError: rx/Observable
at feign.hystrix.HystrixDelegatingContract.parseAndValidatateMetadata(HystrixDelegatingContract.java:42) ~[feign-hystrix-9.3.1.jar:na]
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146) ~[feign-core-9.3.1.jar:na]
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53) ~[feign-core-9.3.1.jar:na]
at feign.Feign$Builder.target(Feign.java:209) ~[feign-core-9.3.1.jar:na]
at org.springframework.cloud.netflix.feign.HystrixTargeter.target(HystrixTargeter.java:48) ~[spring-cloud-netflix-core-1.2.3.RELEASE.jar:1.2.3.RELEASE]
at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:146) ~[spring-cloud-netflix-core-1.2.3.RELEASE.jar:1.2.3.RELEASE]
at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:167) ~[spring-cloud-netflix-core-1.2.3.RELEASE.jar:1.2.3.RELEASE]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE]
... 55 common frames omitted

Caused by: java.lang.ClassNotFoundException: rx.Observable
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
... 63 common frames omitted

As far as I can tell, the error appears to be being caused by a missing dependency on RxJava that results in the rx.Observable class not being available. However, after adding an RxJava dependency to the schedule checker service's pom.xml and running mvn clean install , the error detailed above persists. I'm unsure as to how to solve this issue since there doesn't appear to be any resources available online that address this problem in particular. The relevant classes/files from the two microservices I've built that should enable the behaviour I'm expecting (the schedule checker service consumes schedule provision service data through the REST endpoint defined in the schedule provision service):

Schedule Provision Service

Main Application Class

@SpringBootApplication
@EnableEurekaClient
public class EmailArrivalScheduleServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(EmailArrivalScheduleServiceApplication.class, args);
    }
}

Schedule Provider REST Controller

@RestController
public class ScheduleDatabaseController {

    @Autowired
    private ScheduleDatabaseService scheduleDatabaseService;

    @RequestMapping(value="/schedules", method=RequestMethod.GET)
    public Iterable<Schedule> getSchedules(){
        return this.scheduleDatabaseService.getSchedules();
    }
}

bootstrap.yml

spring:
  application:
    name: email-arrival-schedule-service

eureka:
  instance:
    prefer-ip-address: true
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

Schedule Checker Service

Main Application Class

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableScheduling
@IntegrationComponentScan
public class EmailArrivalMonitoringApplication {

    public static void main(String args[]) {
        SpringApplication.run(EmailArrivalMonitoringApplication.class, args);
    }
}

Feign Client Interface

@FeignClient("email-arrival-schedule-service")
public interface ScheduleDatabaseFeignClient {

    @RequestMapping(method = RequestMethod.GET, value = "/schedules")
    public List<Schedule> getSchedules();
}

Schedule Provision Consumer

@Service
public class ScheduleServiceImpl implements ScheduleService {

    @Autowired
    private ScheduleDatabaseFeignClient scheduleDatabaseClient;

    @Override
    public List<Schedule> getSchedules() {
        return scheduleDatabaseClient.getSchedules();
    }
}

bootstrap.yml

spring:
  application:
    name: email-arrival-monitoring-service

eureka:
  instance:
    prefer-ip-address: true
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

pom.xml (dependencies only)

<dependencies>
    <dependency>
        <groupId>${project.parent.groupId}</groupId>
        <artifactId>email-arrival-dto</artifactId>
        <version>${project.parent.version}</version>
    </dependency>

    <dependency>
        <groupId>io.reactivex.rxjava2</groupId>
        <artifactId>rxjava</artifactId>
        <version>2.0.8</version>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

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

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-ribbon</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-feign</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-file</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-java-dsl</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-mail</artifactId>
    </dependency>

    <dependency>
        <groupId>com.icegreen</groupId>
        <artifactId>greenmail-spring</artifactId>
        <version>1.5.3</version>
    </dependency>

    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>

After preparing this question, I resolved the issue with 2 co-workers help. The changes to be made are as follows:

  1. RxJava is declared as a dependency by a number of Spring Boot dependencies so, the RxJava dependencies declared by these should be excluded to prevent conflicts.
  2. A particular version of RxJava appears to be needed, I have included a dependency on the 1.0.12 version and this appears to be part of resolving the problem.
  3. The project containing the services I'm building is a multi-module Maven project and as such, there is a parent pom.xml file. In this file, there is a dependency on org.springframework.cloud.spring-cloud-dependencies.pom.xml . The version of this dependency was set to Camden.SR3 but is now defined to be Dalston.RELEASE . Changing the version back to Camden.SR3 appears to cause the error defined in my original question.
  4. There is some auto-configuration of beans performed by this spring-cloud-netflix class . This seems to cause the java.lang.ClassNotFoundException: rx.Observable issue mentioned. To resolve this, add the following annotation to the application class of the service that contains the Feign Client you want to set-up: @EnableAutoConfiguration(exclude = {RxJavaAutoConfiguration.class})

In summation, the changes to be made are as follows. With regard to the schedule checker service pom.xml (not the parent pom for the whole project), all other code remains as detailed in my original question:

Schedule Checker Parent

pom.xml

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Dalston.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Schedule Checker Service

pom.xml

<dependencies>
    <dependency>
        <groupId>io.reactivex</groupId>
        <artifactId>rxjava</artifactId>
        <version>1.0.12</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-ribbon</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.reactivex</groupId>
                <artifactId>rxjava</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.reactivex</groupId>
                <artifactId>rxjava</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-feign</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.reactivex</groupId>
                <artifactId>rxjava</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

Application Class

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@EnableScheduling
@IntegrationComponentScan
@EnableAutoConfiguration(exclude = {RxJavaAutoConfiguration.class})
public class EmailArrivalMonitoringApplication {

    public static void main(String args[]) {
        SpringApplication.run(EmailArrivalMonitoringApplication.class, args);
    }
}

Finally, it may be the case that: after running mvn clean install on your project (as I did), and starting the Eureka discovery service and services that should communicate (in my case, the schedule provision service and the schedule checker service), that the service containing the Feign Client throws an exception. I'm unsure as to why this occurs but, if you terminate the service and start it again, everything works well together.

I hope this helps, its taken me around 2 days to rectify this issue and I would urge the relevant persons at Spring Boot to update their documentation quickly and accordingly!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM