Tag Archives: eureka server

[Solved] Error in registering Eureka for spring cloud micro service: classnotfoundexception: org.apache.http.conn.scheme.schemeregistry

1. Problem description

As mentioned above, it is normal to start the Eureka server alone. When you start the micro service module and register the service with Eureka, an error is reported.

My microservice module POM depends on the following:

<dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.1</version>
        </dependency>

    </dependencies>

Microservice module configuration file:

eureka.client.service-url.defaultZone=http://localhost:8000/eureka

The total POM of the project is as follows:

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR5</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

2. Solution

See a similar problem on stack overflow:

https://stackoverflow.com/questions/28217891/java-lang-classnotfoundexception-org-apache-http-config-registrybuilder

It is speculated that there may also be a problem with the dependent package under D: \ D1 \ Java \ maven \ repo \ ORG \ Apache \ httpcomponents

According to the time of the file modification date, the following package should be called for the use of Eureka

Delete these folders and reintroduce the POM dependency of microservice module and Eureka server

Start the microservice here and the problem is solved

16:31:17.183- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Getting all instance registry info from the eureka server
16:31:17.460- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :The response status is 200
16:31:17.462- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Starting heartbeat executor: renew interval is: 30
16:31:17.465- INFO 38700 --- [           main]c.n.discovery.InstanceInfoReplicator     :InstanceInfoReplicator onDemand update allowed rate per min is 4
16:31:17.470- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Discovery Client initialized at timestamp 1628843477468 with initial instances count: 0
16:31:17.472- INFO 38700 --- [           main]o.s.c.n.e.s.EurekaServiceRegistry        :Registering application COURSE-LIST with eureka with status UP
16:31:17.472- INFO 38700 --- [           main]com.netflix.discovery.DiscoveryClient    :Saw local status change event StatusChangeEvent [timestamp=1628843477472, current=UP, previous=STARTING]
16:31:17.475- INFO 38700 --- [nfoReplicator-0]com.netflix.discovery.DiscoveryClient    :DiscoveryClient_COURSE-LIST/LAPTOP-LMMPH4VI:course-list:8080: registering service...
16:31:17.523- INFO 38700 --- [           main]o.s.b.w.embedded.tomcat.TomcatWebServer  :Tomcat started on port(s): 8080 (http) with context path ''
16:31:17.524- INFO 38700 --- [           main].s.c.n.e.s.EurekaAutoServiceRegistration :Updating port to 8080
16:31:17.567- INFO 38700 --- [nfoReplicator-0]com.netflix.discovery.DiscoveryClient    :DiscoveryClient_COURSE-LIST/LAPTOP-LMMPH4VI:course-list:8080 - registration status: 204
16:31:19.133- INFO 38700 --- [           main]com.fanyu.course.CourseListApplication   :Started CourseListApplication in 13.313 seconds (JVM running for 14.906)