首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将Zuul网关配置移动到配置服务器

如何将Zuul网关配置移动到配置服务器
EN

Stack Overflow用户
提问于 2020-04-17 07:35:05
回答 1查看 516关注 0票数 1

我从微服务体系结构和spring云开始。我正在尝试从Spring配置服务器获取我的spring网关的配置。我在网关服务的bootstrap.properties文件中添加了以下属性:

gateway.api.=api-网关

spring.cloud.config.uri=http://localhost:8888

spring.profiles.active=dev

尽管这些属性适用于所有其他服务,但对于网关,它们不起作用。我为网关使用的注释是:

代码语言:javascript
运行
复制
@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }

}

其他服务的注释仅为:

代码语言:javascript
运行
复制
@SpringBootApplication

我的配置服务器有一个连接的git存储库,其中包含一个文件: api-gateway-dev.properties

网关日志:

::Spring ::(v2.3.0.M4)

2020-04-17 21:42:39.983 INFO 10340 -- restartedMain c.nyo.apigateway.ApiGatewayApplication :下列配置文件处于活动状态: dev 2020-04-17 21:42:41.926警告10340 -- restartedMain o.s.boot.actuate.endpoint.EndpointId :端点ID‘service-注册表包含无效字符,请迁移到有效格式。2020-04-17 21:42:41.969警告10340 -- restartedMain o.s.boot.actuate.endpoint.EndpointId :端点ID 'hystrix.stream‘包含无效字符,请迁移到有效格式。2020-04-17 21:42:42.240 INFO 10340 -- restartedMain o.s.cloud.context.scope.GenericScope : BeanFactory id=a11a283e-7de6-3470-b177-65c08eab7398 2020-04-17 21:42:43.859 INFO 10340 - restartedMain o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat初始化端口: 8765 (http) 2020-04-17 21:42:43.880 INFO 10340 -- restartedMain o.apache.catalina.core.StandardService :启动服务Tomcat

获取配置的服务的日志:

::Spring ::(v2.3.0.M4)

2020-04-17 21:54:01.414 INFO 5180{name='bootstrapProperties-https://my-user@bitbucket.org/my-user/configs.git/users-service.properties'}] { BootstrapPropertySource =‘bootstrapProperties-https://my-user@bitbucket.org/my-user/configs.git/users-service-dev.properties’},BootstrapPropertySource 2020-04-17 21:54:04.197 INFO 5180 - restartedMain c.n.U.UsersServiceApplication :以下配置文件处于活动状态:

  1. 使网关配置动态是否合乎逻辑?
  2. 为什么不从配置服务器获得配置?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-24 07:35:20

发现问题了。我失踪了:

代码语言:javascript
运行
复制
implementation 'org.springframework.cloud:spring-cloud-starter-config'

在我的build.gradle文件依赖项中

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61266290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档