1

I have a springboot application that is deployed to an external tomcat server, everything works in my local with local DB. Now, i have to promote the code to higher environments where the DB configurations are different. I read a lot about profiles with -Dspring.profiles.active=dev etc.., but how will the spring project know which server it is in when its an external tomcat and not using java -jar -Dspring.profiles.active=dev demo-0.0.1-SNAPSHOT.jar

user525146
  • 3,918
  • 14
  • 60
  • 103

3 Answers3

5

You can pass the SPRING_PROFILES_ACTIVE=dev environmental variable using CATALINA_OPTS

  • Assuming i can't use that either, what else can i use ? I'm using Jenkins to build the code & promote. I think there is config in jenkins that knows which server it is ? do you anything like that to configure. delete applications.properties and replace with application-dev.properties – user525146 Aug 17 '17 at 20:24
  • you could use maven (or gradle) profiles then, but it is a different issue than what you asked – Panayiotis Poularakis Aug 17 '17 at 20:31
0

Here is all the ways to externalized properties and setting profiles docs

ndrone
  • 3,524
  • 2
  • 23
  • 37
0

You should link spring boot profile with maven one like this .

Thus you can build your jar package specifying the spring boot wanted profile :

mvn clean install -P Prod
freemanpolys
  • 1,848
  • 20
  • 19