0
votes

I starting to work with spring cloud.

I use spring-cloud-gateway, spring-cloud-config, eureka

For my spring-cloud server, in application.properties

server.port=8888

spring.security.user.name=admin
spring.security.user.password=123

#for file system
spring.profiles.active=native
spring.cloud.config.server.native.search-locations=file:///home/cloud/config

For my spring-cloud server in the bootstrap.properties

spring.application.name=gateway-service
spring.profiles.active=local
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.username=admin
spring.cloud.config.password=123
spring.profiles.active=local

For my discovery-service (eureka) in the bootstrap.properties

spring.application.name=discovery-service
server.port=8761
spring.profiles.active=local
spring.application.name=discovery-service

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

spring.cloud.config.username=admin
spring.cloud.config.password=123

In /home/cloud/config

gateway-service-local.properties

server.port=8889
spring.r2dbc.url=r2dbc:pool:postgresql://localhost:5432/gateway
spring.r2dbc.schema=cloud
spring.r2dbc.username=test
spring.r2dbc.password=test
spring.r2dbc.pool.initial-size=100
spring.r2dbc.pool.max-size=500
spring.r2dbc.pool.max-idle-time=30m
spring.r2dbc.pool.validation-query=SELECT 1

logging-service-local.properties

discovery-service-local.properties

eureka.instance.hostname=localhost
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

What I understand, bootstrap.properties is loaded to be able to setup application, it take config from server and replace application.properties locally so there is no reason to have application.properties locally?

Should the port should be in the config server, what happen to port specified if there are many instance?

1
Although, Its all upon you. But my suggestions, If you are externalizing properties spring config. Then put that in there, so that your system should have single reference point for properties. It will be easy to manage in future.prasingh

1 Answers

0
votes

It really up to you. If you put the port on config server it can be managed externally and will take precedence.