Alex Rivera | Logout

How to specify the default profile that beans will be registered under in Spring?

Asked 2013-01-21T15:38:11.503
20

Given:

<beans ... namespace decelerations>
     <bean id="foo" class="com.example.foo" />
     <beans profile="abc">
         <bean id="bar" class="com.exmaple.bar" />
     </beans>
</bean>

what is the name of the profile that foo is registered under? Is there a way to override foo in another profile definition? Is there a name for the default profile in spring when a profile is not explicitly specified.

Edit
Report

1 Answer

24

Default profile in spring is "default", see this: https://jira.springsource.org/browse/SPR-8203

You can change the default profile in web.xml by doing this:

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

Command line:

-Dspring.profiles.default=production

Env variable:

export spring_profiles_default=production

If active profile is set, it overrides the default.

answered 2013-01-21T16:47:15.167

Your Answer