Reputation: 1821
Let say my application.properties file of my microservice looks like this.
server.port=8023
spring.profiles.active=staging
spring.application.name=service-ws
spring.config.import=optional:configserver:http://my.cloud.config.server:8012/
What I try to achieve is, when I change "spring.profiles.active" to local, I need to use
spring.config.import=optional:configserver:http://localhost:8012/
As Config Server. Instead of
spring.config.import=optional:configserver:http://my.cloud.config.server:8012/
Upvotes: 1
Views: 1873
Reputation: 71
You need to use this format: application-{env}.properties
For example, for local environment: application-local.properties file will do the work.
Upvotes: 2
Reputation: 38290
Create profile application.properties files.
An example:
application.properties - defaults for all profiles.
application-local.properties - property values for the local profile
application-dev.properties - property values for the dev profile
application-kapow.properties - property values for the kapow profile
Note, the profile name is your decision; common values include: local, dev, qa, uat, and prod. "kapow" is a valid profile name. I've seen profiles defined by hostname.
Remember that you can have multiple profiles active at once.
Here is a link to a Baeldung article that discusses Spring profiles
Upvotes: 2