1

I am using Maven inside Eclipse to build and deploy code. I have multiple profiles setup "production","dev" & "test" in the pom.xml. The question is, is there anyway I can get the currently using profile name/id (which is the one passed as the Maven Build Profiles param from Eclipse Run Configurations) from Spring MVC application.

I have tried autowiring org.springframework.core.env.Environment and use getActiveProfiles() as answered in another SO question but the String array returned is empty.

enter image description here

Community
  • 1
  • 1
Min Naing Oo
  • 1,085
  • 5
  • 24
  • 49
  • 4
    maven profiles / spring profiles are different things –  Mar 20 '17 at 06:46
  • 1
    One option is to define a property specific for each maven profile and use that, see http://stackoverflow.com/questions/11500533/access-maven-properties-defined-in-the-pom for example. You also could set the property `spring.profiles.active` (for each profile in the pom) and use spring profile, see http://stackoverflow.com/questions/38520638/how-to-set-spring-profile-from-system-variable for example –  Mar 20 '17 at 06:48
  • `maven profiles / spring profiles are different things` this comment made me realize i'm doing it all wrong.. Thank you @RC. – Min Naing Oo Mar 20 '17 at 07:49

0 Answers0