- Mastering Spring Cloud
- Piotr Minkowski
- 162字
- 2021-08-27 18:57:08
Building a client-side application
If you set port 8888 as the default for the server, the configuration on the client side is really simple. All you need to do is to provide the bootstrap.yml file with the application name and include the following dependency in your pom.xml. Of course, that rule is applicable only on localhost, because the auto-configured Config Server address for a client is http://localhost:8888:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
If you set a port different than 8888 for the server, or it is running on a different machine than the client application, you should also set its current address in bootstrap.yml. Here are the bootstrap context settings, which allow you to fetch properties for client-service from the server available on port 8889. When running the application with the --spring.profiles.active=zone1 argument, it automatically fetches the properties set for the zone1 profile in the configuration server:
spring:
application:
name: client-service
cloud:
config:
uri: http://localhost:8889