Eureka的客户端的创建

步骤一

引入maven配置,我这里用的是
下面就是引用的父类的版本:Dalston.SR1

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Dalston.SR1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

下面使用的是Eureka客户需要引用的包,此处的版本号是通过parent里面设定了,

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

步骤二

配置application.yml

server:
  port: 8001

eureka:
  client:
    service-url:
       defaultZone: http://eureka7001.com:7001/eureka/ #这里根据自己的情况而定

步骤三

启动类添加开启服务注解,开启EurekaServer@EnableEurekaClient

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

测试:

可以访问localhost:7001就可以访问eureka的服务页面查看已经注册进去的客户端

file

客户端注册进服务端的名称的修改

修改前是:localhost:debugggcloud-dept:8001
修改后是:debugggcloud-dept8001
步骤:

步骤一:修改application.yml的

```
eureka:
  client:
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
  instance:
    instance-id: microservicecloud-dept8001 #新增的instance-id
```

客户端注册服务端的名称的地址栏有IP信息提示

eureka:
  client:
    service-url:
      defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/
  instance:
    instance-id: microservicecloud-dept8001
    prefer-ip-address: true #新增的这一行

info信息的配置步骤

1.在客户端工程里面加入

<!--        监控信息完善-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2.在parent工程里面加入build构建工具

<build>
        <finalName>debugggcloud</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <delimiters>
                        <delimit>$</delimit>
                    </delimiters>
                </configuration>
            </plugin>
        </plugins>
    </build>

3.在客户端工程里面的yml文件里面加入info节点,代码如下

info:
  app.name: atguigu-microservicecloud
  company.name: www.atguigu.com
  build.artifactId: ${project.artifactId}
  build.version: ${project.version}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值