springmavenspring-tool-suitetcserverspring-profiles

spring profile not activated on STS tc Server


I have a project with Spring profile

In my web.xml, i have

<context-param>
    <param-name>spring.profiles.default</param-name>
    <param-value>dev</param-value>
</context-param>

to set the default spring profile.

I build the maven project with

clean install -Dspring.profiles.active="prod"

Then, I choose the option Run As -> Run on Server to deploy the maven project to tc Server.

However, the active profile is still dev.

What is the correct way to activate a spring profile on tc Server


Solution

  • If you are running your app from with STS and the tc Server that comes with it, you can put the system property definition into the launch configuration of tc Server. Once you started up tc Server once, you can modify the lauch config via "Run Configurations...", select the one for Pivotal tc Server, go to the VM arguments and add the -Dspring.profiles.active=prod setting.

    Since this is a runtime option, it doesn't have any effect while building the app via Maven (the clean install way you tried).