Learning blog: [SpringCloud] Eureka registered service consumers

First import dependencies

<?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">
    <parent>
        <artifactId>springcloud</artifactId>
        <groupId>com.yl</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>springcloud-consumer-dept-80</artifactId>

    <dependencies>

        <!--实体类-->
        <dependency>
            <groupId>com.yl</groupId>
            <artifactId>springcloud-api</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!--web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
    </dependencies>

</project>

Configuration file application.xml

server:
  port: 80

spring:
  application:
    name: springcloud-consumer-dept


eureka:
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
    register-with-eureka: true
    fetch-registry: true
  instance:
    instance-id: springcloud-consumer-dept80  #描述信息
    prefer-ip-address: true #优先使用ip注册,访问显示ip



management:
  endpoints:
    web:
      exposure:
        include: "*"
  info:
    env:
      enabled: true

# 暴露端点info
info:
  app.name: yl-springcloud
  company.name: www.yl.com
  build.artifactId: com.yl.springcloud
  build.version: 1.0-SNAPSHOT

insert image description here
Turn on annotations in the main startup class

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

insert image description here

Guess you like

Origin blog.csdn.net/Aurinko324/article/details/125648942