spring-boot: Active profile setting in application.properties periodically ignored

Application uses Spring Boot 2.0.2.RELEASE

application.properties file has the following entry: spring.profiles.active=local

When running the application (in IntelliJ or by running the application jar from the command line), the application will sometimes ignore the active profile setting (around 30% of the time). The application configurations that are annotated to be registered for a ‘local’ profile are ignored, and the console output will display this line: No active profile set, falling back to default profiles: default

This behavior is unpredictable. The only solution is to try restarting the application (sometimes multiple times) until the active profile is set correctly.

The salient point is that restarting the application without making any changes will eventually correct the problem.

Let me know what other information you need. I can’t hand over this application, and creating an app that reproduces this problem is probably not viable (none of my other Spring Boot apps behave this way, and nothing obvious makes this one different). Perhaps a logging trace will provide helpful information?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Another clue. I added logging.level.org.springframework=TRACE to applications.properties. When I start the application, if the console output states No active profile set, falling back to default profiles: default, then no tracing statements are logged. If the console output states that the active profile is ‘local’, then the console output includes tracing statements.

Remember, I added logging.level.org.springframework=TRACE to application.properties, not to application-local.properties. It seems like the Spring Framework is sometimes failing to either find, open, or read the application.properties file.