Eureka's default environment variables

When using Eureka, if it is a client, generally set eureka in bootstrap.yml, such as:

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8716/eureka/

Among them, the defaultZone setting is the address of Eureka Server, but if it is written in the configuration file, it will be written to death. Usually, it can be set through environment variables, which is more flexible.

eureka:
  client:
    service-url:
      defaultZone: ${EUREKA_SERVER_URL}

How to set the address of Eureka through environment variables is much more flexible.

So does each eureka client need to be set?

In fact, if we do not set the configuration of eureka, that is, if we do not configure any configuration of eureka in bootstarp.yml, then there is a default environment variable to set the address of eureka server. This environment variable is: EUREKA_URL.

Other configurations of eureka remain default.

In the process of use, it is found that other configurations of eureka-client are also more important.

for example:

eureka:
  client:
    fetch-registry: false # 要不要去注册中心获取其他服务的地址
    register-with-eureka: false     # false表示不向注册中心注册自己
    service-url:
      defaultZone: ${EUREKA_URL}

Guess you like

Origin blog.csdn.net/kanyun123/article/details/118224524