3.eureka

1.导入相关的依赖--注意版本关系
修改完版本号,有时候更新过慢
可以rebulier project
image

新建module,导入jar报后配置注解
image

导入jar包
注意版本间的关系
image

  <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
            <version>1.4.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

配置application
image

server:
  port: 7001

# Eureka配置
eureka:
  instance:
    hostname: localhost # Eureka服务端名称
  client:
    register-with-eureka: false # false表示注册自己
    fetch-registry: false
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/


开启服务后,访问7001端口
image

服务端注册到Eureka

导入Eureka
image

    <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
            <version>1.4.5.RELEASE</version>
        </dependency>

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

application中的eureka配置

# Eureka配置
eureka:
  client:
    service-url:
      defaultZone: http://localhost:7001/eureka/
  instance:
    instance-id: springcloud-provider-dept8001

info:
  app.name: chuan-springcloud
  company.name: blog.chuanstudy.com

image
加上注解
image
访问7001
image
注册陈宫

posted @ 2022-08-11 20:48  拿受用  阅读(15)  评论(0编辑  收藏  举报