0

Based on this post, I run my Spring Boot application with

./gradlew bootRun -Dspring-boot.run.profiles=foo

A component with the profile doesn't run. And I try to verify the active profile with the following code in the root Application class

  @Autowired
  private Environment environment;

  @PostConstruct
  void postConstruct(){
    String[] activeProfiles = environment.getActiveProfiles();
    log.info("active profiles: {}", 
    Arrays.toString(activeProfiles));
  }

The log message output is blank.

What is missing?

Rainbow
  • 61
  • 1
  • 7

1 Answers1

0

-Dspring-boot.run.profiles=foo only works with maven. So it will not work with gradle. You can find informaiton on how to bootrun with gradle here.

Shawrup
  • 2,478
  • 2
  • 12
  • 21