Set up eureka,gateway,admin,redis,docker series

Eureka Yes. Netflix Developed, a REST service based, service registration and discovery component

It mainly includes two components: Eureka Server and Eureka Client

  • Eureka Client: a Java client used to simplify the interaction with Eureka Server (usually the client and server in microservices)
  • Eureka Server: provides service registration and discovery capabilities (usually the registry in microservices)

Set up the registry server (create an empty module)

pox dependence

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>

            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.1.2.RELEASE</version>
             <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency> 
    </dependencies>
<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

Create a startup class

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
    public static void main(String[] args) {

        SpringApplication.run(EurekaApplication.class, args);
    }
}

configuration file

#config
spring.application.name=eurekaserver
server.port=8761

eureka.instance.instance-id=${eureka.instance.ip-address}:${server.port}/${spring.application.name}
eureka.client.service-url.defaultZone=http://127.0.0.1:8761/eureka
#Since the app is a registry, setting it to false indicates that it does not register itself with the registry
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=ALWAYS

The simple eureka is completed. You can see the registration center by directly starting and inputting localhost:8761

Tags: Java Spring REST log4j

Posted on Thu, 26 Mar 2020 10:32:37 -0400 by wizzkid