Skip to content

Showcase how Spring profiles can be managed from external configuration

Notifications You must be signed in to change notification settings

bsblabs/spring-profile-showcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spring profile showcase

The purpose of this showcase is to demonstrate how easy it is to customize how a Spring application context starts. See this blog post for an excellent introduction.

Our goal is to enable a set of profile(s) based on a properties file loaded from the classpath. This implementation loads from META-INF/application-context.xml but it could be any other location you may desire.

Building from Source

Clone the git repository using the URL on the Github home page:

$ git clone git@github.com:bsblabs/spring-profile-showcase.git
$ cd spring-profile-showcase

Command Line

Use Maven, then on the command line:

$ mvn install

Make sure you have access to the central repository.

Usage

To use this showcase, add the following to your web.xml

<context-param>
    <param-name>contextInitializerClasses</param-name>
    <param-value>com.bsb.showcase.spring.profile.ProfilesActivationApplicationInitializer</param-value>
</context-param>

And add a file located in META-INF/application-context.properties with the profiles you would like to enable.

spring.profiles.active=env1,service2

Because the property source is added last, any system or environment property will take precedence. This basically means that even when this is active you can start your application (server) with -Dspring.profiles.active=env1,service5 to override the default behavior.

About

Showcase how Spring profiles can be managed from external configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published