maventomcatspring-bootpom.xmlmaven-tomcat-plugin

tomcat7-maven-plugin to deploy spring boot with appropriate spring profile selected


My goal is to be able to use the tomcat-maven plugin to deploy my spring boot application from the command line where an argument is supplied that tells spring which profile to use like this:

mvn tomcat7:deploy -Dspring.profiles.active="dev"

I've tried several different things such as the solution described here but the default application.properties is still always selected.

The only way that I've been able to get the application-dev.properties selected is by using

mvn spring-boot:run -Dspring.profiles.active="dev"

But we don't want to have tomcat packaged in our war

I'm new to maven and spring boot and I've been spinning my wheels for the better part of a a day now so any advice would be appreciated.


Solution

  • I found out the issue and I was able to get the correct profile selected using export SPRING_PROFILES_ACTIVE=dev. The problem that I was having was when I was starting my local tomcat server through the eclipse UI my environment variables were being ignored. When starting tomcat through startup.bat the environment variable gets used and spring uses the correct profile.