我从微服务体系结构和spring云开始。我正在尝试从Spring配置服务器获取我的spring网关的配置。我在网关服务的bootstrap.properties文件中添加了以下属性:
gateway.api.=api-网关
spring.cloud.config.uri=http://localhost:8888
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
网关日志:
::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 :以下配置文件处于活动状态:
发布于 2020-04-24 07:35:20
发现问题了。我失踪了:
implementation 'org.springframework.cloud:spring-cloud-starter-config'在我的build.gradle文件依赖项中
https://stackoverflow.com/questions/61266290
复制相似问题