加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Eureka 注册中心 和 Config中心 配置

发布时间:2020-12-15 08:24:37 所属栏目:Java 来源:网络整理
导读:Eureka config: 1 import spring-cloud-starter-netflix-eureka-client jar in pom.xml dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependency ? 2 add @EnableDiscoveryClient

Eureka config:

1 import spring-cloud-starter-netflix-eureka-client jar in pom.xml

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

?

2 add @EnableDiscoveryClient in startup class “application.java”

3 add configuration in yml.

eureka:

  client:

    service-url:

      defaultZone: http://hostname:port/eureka # eureka server

?

?Config中心:

1 import spring-cloud-starter-config jar in pom.xml

<dependency>

   <groupId>org.springframework.cloud</groupId>

   <artifactId>spring-cloud-starter-config</artifactId>

</dependency>

?

2 add configuration in bootstrap.yml

spring:

  application:

    name: apexa-fx-data-grabber

  cloud:

    config:

      uri: http://hostname:port/ # config server

      name: fx-cient # application name

?

3 add configuration files in git repo?assigned by config server?

?

4 do not need to restart server to change configuration

First,add spring-boot-starter-actuator jar in pom.xml.

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

?

Then,add configuration in bootstrap.yml

management:

  endpoints:

    web:

      exposure:

        include: refresh

?

and add Annotate Your configuration beans and beans where annotation Value is used with annotation @RefreshScope

?

after changing configuration,need to post http://[instance host]:[port]/actuator/refresh to valid it.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读