Euraka server simple configuration

Euraka server simple configuration

Registration center, mainly used to call
microservices. Parent project pom dependency

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.123</groupId>
    <artifactId>changgou-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <modules>
        <module>eureka</module>
    </modules>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
    </parent>

    <!--编译跳过测试-->
    <properties>
        <skipTest>true</skipTest>
    </properties>

    <dependencies>

        <!--测试-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>

        <!--fastjson-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.51</version>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR1</version>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

1. Create a project

Insert picture description here
Insert picture description here
Insert picture description here

2. Introduce dependencies

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

Insert picture description here

3. Create a configuration file

spring.application.name = eureka


server.port = 7001
eureka.instance.hostname = 127.0.0.1

# 是否注册自己的信息,做主备时会使用
eureka.client.register-with-eureka=false
# 是否从eureka中获取信息
eureka.client.fetch-registry = false
eureka.client.service-url.defaultZone = http://${eureka.instance.hostname}:${server.port}/eureka/

3. Create a startup class

Insert picture description here

@SpringBootApplication
@EnableEurekaServer  //开启eureka服务
public class EurekaApplication {

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

4. Start the service

Insert picture description here
Make a URL visit

Insert picture description here

Guess you like

Origin blog.csdn.net/Guesshat/article/details/113805905