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

Spring 如何将Zuul网关配置移动到配置服务器,spring,spring-boot,microservices,spring-cloud,netflix-zuul,Spring,Spring Boot,Microservices,Spring Cloud,Netflix Zuul,我从微服务架构和spring云开始。 我正在尝试从Spring配置服务器获取Spring Zuul网关的配置。 我在网关服务的bootstrap.properties文件中添加了以下属性: spring.application.name=api网关 spring.cloud.config.uri= spring.profiles.active=dev 尽管这些属性适用于所有其他服务,但对于网关,它们不起作用。 我用于网关的注释有: @EnableZuulProxy @EnableDiscover

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

spring.application.name=api网关

spring.cloud.config.uri=

spring.profiles.active=dev

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

@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ApiGatewayApplication {

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

}
其他服务的注释仅限于:

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

网关日志:

::弹簧靴::(v2.3.0.M4)

2020-04-1721:42:39.983信息10340---[重新启动主站] c、 nyo.apigateway.ApiGatewayApplication:以下配置文件是 活动:dev 2020-04-17 21:42:41.926警告10340---[restartedMain] o、 s.boot.actuate.endpoint.EndpointId:端点ID “服务注册表”包含无效字符,请迁移到 有效格式。2020-04-1721:42:41.969警告10340---[ restartedMain]o.s.boot.actuate.endpoint.EndpointId:端点ID “hystrix.stream”包含无效字符,请迁移到 有效格式。2020-04-1721:42:42.240信息10340---[ restartedMain]o.s.cloud.context.scope.GenericScope:BeanFactory id=a11a283e-7de6-3470-b177-65C08EAB73982020-04-1721:42:43.859信息 10340---[restartedMain]o.s.b.w.embedded.tomcat.TomcatWebServer: Tomcat已用端口初始化:8765(http)2020-04-17 21:42:43.880 信息10340---[restartedMain] o、 apache.catalina.core.StandardService:启动服务[Tomcat]

正在获取配置的服务的日志:

::弹簧靴::(v2.3.0.M4)

2020-04-17 21:54:01.414信息5180---[重新启动主站] c、 c.c.ConfigServicePropertySourceLocator:正在从服务器获取配置 电话:2020-04-1721:54:04.184信息5180---[ restartedMain]c.c.c.ConfigServicePropertySourceLocator:位于 环境:name=users服务,profiles=[dev],label=null, 版本=244114F5A11A7D4A0ACB57050DDAD144F7DE1BE5,状态=null 2020-04-17 21:54:04.186信息5180---[重新启动主站] b、 c.PropertySourceBootstrapConfiguration:定位的属性源: [BootstrapPropertySource{name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-'}, BootstrapPropertySource {name='bootstrapproperty-'}] 2020-04-1721:54:04.197信息5180---[重新启动主站] c、 n.U.UsersServiceApplication:以下配置文件是 活动:dev

  • 使网关配置动态化是否合乎逻辑

  • 为什么我不从配置服务器获取配置


  • 发现了问题。我失踪了:

    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    

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

    找到了问题。我失踪了:

    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    

    在my build.gradle文件依赖项中

    是的,它应该可以工作。什么不起作用?应该有日志条目试图连接到配置服务器,您可以添加它们吗?你能打吗?我加了logsYes,应该可以。什么不起作用?应该有日志条目试图连接到配置服务器,您可以添加它们吗?你能打吗?我已经添加了日志