Noy Oliel
Noy Oliel

Reputation: 1696

How to move Zuul gateway configurations to configuration server

I'm starting out with microservices architecture and spring cloud. I'm trying to get configurations for my Spring Zuul Gateway from the spring configuration server. I've added below properties in bootstrap.properties file of the gateway service:

spring.application.name=api-gateway

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

spring.profiles.active=dev

Even though these properties work for all other services, for the gateway they do not work. The annotations I'm using for the gateway are:

@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ApiGatewayApplication {

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

}

The annotation for other services is only:

@SpringBootApplication

My configuration server has a connected git repository with a file: api-gateway-dev.properties

logs of gateway:

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

2020-04-17 21:42:39.983 INFO 10340 --- [ restartedMain] c.nyo.apigateway.ApiGatewayApplication : The following profiles are active: dev 2020-04-17 21:42:41.926 WARN 10340 --- [ restartedMain] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format. 2020-04-17 21:42:41.969 WARN 10340 --- [ restartedMain] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format. 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 initialized with port(s): 8765 (http) 2020-04-17 21:42:43.880 INFO 10340 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]

logs of a service that is getting configurations:

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

2020-04-17 21:54:01.414 INFO 5180 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888 2020-04-17 21:54:04.184 INFO 5180 --- [ restartedMain] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=users-service, profiles=[dev], label=null, version=244114f5a11aa7d4a0acb5750ddad144f7de1be5, state=null 2020-04-17 21:54:04.186 INFO 5180 --- [ restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://[email protected]/my-user/configs.git/users-service-dev.properties'}, BootstrapPropertySource {name='bootstrapProperties-https://[email protected]/my-user/configs.git/users-service.properties'}] 2020-04-17 21:54:04.197 INFO 5180 --- [ restartedMain] c.n.U.UsersServiceApplication : The following profiles are active: dev

  1. Is it logical to make gateway configuration dynamic?

  2. Why don't I get the configuration from the configuration server?

Upvotes: 1

Views: 686

Answers (1)

Noy Oliel
Noy Oliel

Reputation: 1696

Found the problem. I was missing:

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

in my build.gradle file dependencies

Upvotes: 0

Related Questions