Sïd
Sïd

Reputation: 65

Spring boot project with embedded Tomcat & multiple environments

I've a Spring boot(with embedded tomcat 8) project with multiple server components that get deployed in multiple env(dev/test/prod) How do you make one jar that can be deployed into multiple env in such a way that in each env the jar will pick up appropriate env params such as db and other server urls that each env supposed to use. The objective is not to touch the jar file which invalidates QA process. If it's traditional deployment, I typically change a flag in the properties file to indicate the env and the rest of the properties are read based on that param.

Upvotes: 0

Views: 472

Answers (1)

imTachu
imTachu

Reputation: 3809

You package your jar (or war) as mvn package and then to execute add a -D.spring.profiles.active parameter setting your environment: something like: mvn spring-boot:run -Dspring.profiles.active=dev

Check this and this documentation.

Upvotes: 2

Related Questions