0

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.

Sïd
  • 65
  • 2
  • 11
  • 1
    Should have a look at spring profiles: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html *"Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments"* – Sid Jun 22 '16 at 16:53
  • @Sid Thanks a lot. This helps – Sïd Jun 23 '16 at 16:41

1 Answers1

2

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.

imTachu
  • 3,759
  • 4
  • 29
  • 56