Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

How do you get the active Springframework profiles?
Inject the Environment object

    @Autowired
    private Environment environment;

The Environment object has getActiveProfiles that returns an array of active profiles. To get the first active profile, do…

String profile = environment.getActiveProfiles()[0];

February 11th, 2014

Posted In: Spring, Spring Profile

Tags: , , ,

Leave a Comment

LinkedIn Auto Publish Powered By : XYZScripts.com