Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use Spring Boot properties depending on the active profile

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

spring.config.import=optional:configserver:http://my.cloud.config.server:8012/

>Solution :

You need to use this format: application-{env}.properties

For example, for local environment: application-local.properties file will do the work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading