Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 727
ams Avatar asked Jan 21 '13 15:01

ams


1 Answers

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.

like image 81
Solubris Avatar answered Sep 20 '22 11:09

Solubris