Skip to content

Commit 6e341b9

Browse files
committed
docs: clarify cloud profile activation in java-cfenv docs
The `cloud` Spring profile is activated by CloudProfileApplicationListener, which ships only in the java-cfenv-all module (not java-cfenv-boot or the core module). Correct the framework doc and the migration guide's troubleshooting entry, and show SPRING_PROFILES_INCLUDE (add alongside existing profiles) vs SPRING_PROFILES_ACTIVE (replace) for explicit activation. Refs #1349.
1 parent 0846298 commit 6e341b9

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

docs/framework-java-cfenv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ The Java CfEnv Framework provides the `java-cfenv` library for Spring Boot 3.x a
33

44
This is the recommended replacement for Spring AutoReconfiguration library which is deprecated. See the `java-cfenv` <a href="https://github.com/pivotal-cf/java-cfenv">repository</a> for more details.
55

6-
The included `java-cfenv` library activates the `cloud` Spring profile at runtime when `VCAP_SERVICES` is present, as the Spring AutoReconfiguration framework did. The buildpack itself does not set any Spring profile.
6+
The `cloud` Spring profile is activated at runtime by java-cfenv's `CloudProfileApplicationListener`, which ships in the `java-cfenv-all` module. To ensure the profile is active — or to activate it independently of java-cfenv — set it explicitly. Use `SPRING_PROFILES_INCLUDE=cloud` to add `cloud` alongside any other active profiles, or `SPRING_PROFILES_ACTIVE=cloud` to set it as the sole active profile (this replaces any others). The buildpack itself does not set any Spring profile.
77

88
The buildpack selects the appropriate `java-cfenv` version based on the detected Spring Boot major version:
99

docs/spring-auto-reconfiguration-migration.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
This guide provides step-by-step instructions for migrating from the deprecated **Spring Auto-reconfiguration** framework to **java-cfenv**.
44

5+
> **Note — the `cloud` Spring profile**
6+
>
7+
> Spring Auto-reconfiguration activated a Spring profile named `cloud`. java-cfenv only
8+
> activates that profile if the `java-cfenv-all` module is on the classpath (it contains
9+
> `CloudProfileApplicationListener`); the `java-cfenv-boot` module does **not**. If your
10+
> application relies on the `cloud` profile — for example `application-cloud.yml` /
11+
> `application-cloud.properties` or `@Profile("cloud")` beans — either use `java-cfenv-all`,
12+
> or activate it explicitly. If the application already sets other active profiles, use
13+
> `SPRING_PROFILES_INCLUDE` to add `cloud` alongside them:
14+
>
15+
> ```bash
16+
> cf set-env <APP> SPRING_PROFILES_INCLUDE cloud # adds 'cloud' to any existing profiles
17+
> cf restage <APP>
18+
> ```
19+
>
20+
> Use `SPRING_PROFILES_ACTIVE=cloud` only if `cloud` should be the sole active profile (it
21+
> replaces any others).
22+
523
---
624
725
## Table of Contents
@@ -453,16 +471,23 @@ public class CustomConfig {
453471
454472
### Issue: "cloud" profile not active
455473
456-
**Cause**: java-cfenv only activates "cloud" profile on Cloud Foundry
457-
458-
**Solution**: This is expected. Locally, the "cloud" profile won't be active.
474+
**Cause**: The `cloud` profile is activated by `CloudProfileApplicationListener`, which ships
475+
only in the `java-cfenv-all` module. The `java-cfenv-boot` dependency shown above does **not**
476+
activate it. If you previously depended on the `cloud` profile under Spring Auto-reconfiguration,
477+
it will not be active after migrating to `java-cfenv-boot` alone.
459478
460-
To test cloud profile locally:
479+
**Solution**: Either depend on `java-cfenv-all` instead of `java-cfenv-boot`, or activate the
480+
profile explicitly. If the application already sets other active profiles, add `cloud` alongside
481+
them with `SPRING_PROFILES_INCLUDE`:
461482
462483
```bash
463-
java -jar myapp.jar --spring.profiles.active=cloud
484+
cf set-env <APP> SPRING_PROFILES_INCLUDE cloud # adds 'cloud' to any existing profiles
485+
cf restage <APP>
464486
```
465487
488+
Use `SPRING_PROFILES_ACTIVE=cloud` only if `cloud` should be the sole active profile (it replaces
489+
any others). To activate it locally: `java -jar myapp.jar --spring.profiles.active=cloud`.
490+
466491
---
467492
468493
## Rollback Plan

0 commit comments

Comments
 (0)