“Eureka Client 演示”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
第44行: 第44行:
 
     </dependencies>
 
     </dependencies>
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
=== 配置文件 ===
 +
 +
==== application.yml ====
 +
<syntaxhighlight lang="yaml">
 +
spring:
 +
  application:
 +
    # 如果没有配置,默认名称 UNKNOWN
 +
    name: demo
 +
 +
eureka:
 +
  client:
 +
    service-url:
 +
      # 下面信息也是默认值
 +
      defaultZone: http://localhost:8761/eureka/
 +
</syntaxhighlight>
 +
 +
==== spring.application.name ====
 +
[[文件:Spring.application.name.png|无|缩略图|624x624像素]]
 +
 +
 +
 +
==== eureka.client.service-url.defaultZone ====
 +
[[文件:Eureka.client.service-url.defaultZone.png|无|缩略图|1023x1023像素]]

2023年3月10日 (五) 01:33的版本

https://www.bilibili.com/video/BV1eU4y187zE/?p=11

Eureka Client 可以向 Eureka Server 中注册自己

导入依赖

注意依赖换成了 Eureka 客户端依赖

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

    <groupId>io.github.jihch</groupId>
    <artifactId>eureka-client</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

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

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

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


配置文件

application.yml

spring:
  application:
    # 如果没有配置,默认名称 UNKNOWN
    name: demo

eureka:
  client:
    service-url:
      # 下面信息也是默认值
      defaultZone: http://localhost:8761/eureka/

spring.application.name

Spring.application.name.png


eureka.client.service-url.defaultZone

Eureka.client.service-url.defaultZone.png