Reputation: 339
I have configured bootstrap.yml for spring config
spring:
application:
name: cce-auth
cloud:
config:
uri: http://temp.com:8888
It works fine but I need URI value Dynamically, for example if I will publish this .war
in test environment this URL must be http://test-temp.com:8888
.
So for this I have solution create config.txt file in server and using I/O Stream reed/write this string to bootstrap.yml.
But problem is loading, spring loads http://localhost:8888
before I'm writing in bootstrap.yml.
So my reason is to create dynamically URI for config server. DO you have any idea?
Upvotes: 0
Views: 2408
Reputation: 11752
Define active_profile in bootstrap.yml
file
spring:
profiles:
active: ${activatedProperties}
Then create bootstrap-${activatedProperties}.yml
for each environment, etc..bootstrap-dev.yml
, bootstrap-pre.yml
, bootstrap-prod.yml
For example:
spring:
application:
name: servicename_prod
cloud:
config:
uri: https://admin:[email protected]:8888
server:
port: 8443
add plugin to pom.xml
file :
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
When run java, define environment on it: for example, run with prod
environment.
java -Dserver.port=8443 -Dspring.profiles.active=prod -jar ....
Upvotes: 2