Skip to content
Latchkey

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.

Spring Boot
The following 1 profile is active: "default"
...
Failed to configure a DataSource: 'url' attribute is not specified

Common 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.

.github/workflows/ci.yml
env:
  SPRING_PROFILES_ACTIVE: ci

Set it on tests with @ActiveProfiles

Pin the profile in test classes so it does not depend on the environment.

src/test/java
@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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →