Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default spring profile?

Tags:

spring

To read a Spring profile I use :

<beans profile="LOC">

I have this property set as a jvm property :

-Dspring.profiles.active=LOC

Is it possible to use some logic just use the profile "LOC" if it exists and it does not exist use a default profile ?

like image 980
blue-sky Avatar asked Jun 01 '26 15:06

blue-sky


1 Answers

This is possible in spring 3.2, where the ! operator has been introduced:

<beans profile="LOC">
    <import resource="LOC.xml"/>
</beans>
<beans profile="!LOC">
    <import resource="default.xml"/>
</beans>

LOC.xml will be included when the LOC profile is active. default.xml will be included if LOC is not defined.

The change has been announced here: http://www.springsource.org/node/3563
and the commit is here: https://github.com/SpringSource/spring-framework/commit/bcd44f3798ed06c0704d2a3564b8a9735e747e87

like image 112
Wojciech Górski Avatar answered Jun 04 '26 13:06

Wojciech Górski