Spring Boot wrong spring.profiles.active in CI
Spring Boot logs "The following 1 profile is active" at startup. When CI shows the wrong profile (or none), it loads config meant for another environment, and beans, datasources, or endpoints behave unexpectedly.
What this error means
Startup logs "The following profile is active: default" (or dev/prod) in CI when you expected test/ci, and downstream failures trace back to the wrong config being loaded.
The following 1 profile is active: "default"
...
Failed to configure a DataSource: 'url' attribute is not specifiedCommon causes
The profile is never set in the CI step
No SPRING_PROFILES_ACTIVE env var or --spring.profiles.active argument is passed, so Spring falls back to default.
A conflicting profile source wins
A profile baked into application.properties or an OS env var overrides the one you intended for CI.
How to fix it
Set the profile explicitly for the CI job
Export SPRING_PROFILES_ACTIVE so every step uses the intended profile.
env:
SPRING_PROFILES_ACTIVE: ciSet it on tests with @ActiveProfiles
Pin the profile in test classes so it does not depend on the environment.
@ActiveProfiles("test")
@SpringBootTest
class OrderFlowTest { }How to prevent it
- Always set spring.profiles.active explicitly in CI.
- Log and assert the active profile at startup so drift is visible.
- Avoid hardcoding a profile in application.properties that CI must override.