简体   繁体   English

使用 Spring Boot 从另一个微服务访问网关属性

[英]Accessing Gateway Properties from another microservice using Spring boot

I have Config Microservice , Employee Microservice , Gateway Microservice .我有Config Microservice , Employee Microservice , Gateway Microservice application.yml will be loaded from Config Microservices for Employee and Gateway Microservice using the Spring.cloud.config . application.yml 将使用Spring.cloud.config从 Config Microservices for Employee 和 Gateway Microservices加载

i need to use one of the Gateway Property in the Employee Microservice .我需要使用员工微服务中的网关属性之一。 how to achieve this ?如何实现这一目标?

Config Microservice contains below files配置微服务包含以下文件

application.yml应用程序.yml

server:
  port: 8080

Gateway.yml网关.yml

app:
 access-table: true

Employee.yml员工.yml

 server:
  port: 8081

In the Employee Microservice, Employee.yml is loaded using the Spring cloud config URI .在 Employee 微服务中,Employee.yml 是使用 Spring 云配置 URI 加载的。

 cloud:
   config:
     uri: http://localhost:8080

how can i access the access-table property from the gateway.yml in the Employee Microservices ?如何从员工微服务中的gateway.yml访问访问表属性?

i tired using name property but it overrides the other configs , i need to access only that property .我厌倦了使用 name 属性,但它覆盖了其他配置,我只需要访问该属性。 is there a way?有办法吗?

cloud:
 config:
  uri: http://localhost:8080
  name: Employee.yml,Gateway.yml

If you have any common properties that required in multiple micro-services then place those properties in config server application.yml .如果您有多个微服务所需的任何公共属性,请将这些属性放在配置服务器application.yml This application.yml for all micro-services even if have any profile.application.yml于所有微服务,即使有任何配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM