Announcement Announcement Module
Collapse
No announcement yet.
spring.profile.active : is there a way to configure default value Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring.profile.active : is there a way to configure default value

    Hi, I am using spring.profile.active feature provided by spring 3.1 in my application, However I am forced to define a system variable with a value. The default value for this token is "Development" by default (if I am not wrong), but i am using dev/prod as value of this variable.

    Is there a way to give a default value for the variable.
    I tried defining the system variable with this name using spring's

    Code:
    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass" value="java.lang.System"/>
        <property name="targetMethod" value="setProperty"/>
        <property name="arguments">
          <list>
            <value>spring.profile.active </value>
            <value>dev</value>
          </list>
        </property>
      </bean>
    But this does not work to me. Any help is appreciated.
    Thanks

  • #2
    The default value for this token is "Development" by default (if I am not wrong),
    No it isn't it is 'default' by default.

    Your solution will not work because the value has to be known at startup time you cannot define it whilst the container is starting.

    To interact with the ApplicationContext there is the ApplicationContextInitializer (which is invoked before the context is started/initialized) this allows you to set a value. You can also simply add an environment variable with the name spring.profile.active and it will be picked up as the active profile.

    Comment


    • #3
      Thanks Marten. Your answer helped us.

      Comment

      Working...
      X