Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch between Prod and Dev environment

I've built a REST Service with Spring Boot. The setup in the development environment is different from the setup in the production environment. What is the best approach to switching setup between development environment and production environment? By setup I mean for instance the path to the database that is different in development vs. production. I can think of three approaches, use environment variables, use a properties file or use config file. Other suggestions are welcome and what I should think about when choosing.

like image 303
g3blv Avatar asked Oct 15 '25 15:10

g3blv


1 Answers

You should have a look at Spring Profiles - see here. Using spring profile, u can easily switch configurations for the different environments.

Just name your configuration for "dev" as "application-dev.(properties|yaml) and provide -Dspring.profiles.active=dev when running the App from command line.

like image 59
dcpastoors Avatar answered Oct 18 '25 08:10

dcpastoors