|
2 | 2 |
|
3 | 3 | This guide provides step-by-step instructions for migrating from the deprecated **Spring Auto-reconfiguration** framework to **java-cfenv**. |
4 | 4 |
|
| 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 | +
|
5 | 23 | --- |
6 | 24 |
|
7 | 25 | ## Table of Contents |
@@ -453,16 +471,23 @@ public class CustomConfig { |
453 | 471 |
|
454 | 472 | ### Issue: "cloud" profile not active |
455 | 473 |
|
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. |
459 | 478 |
|
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`: |
461 | 482 |
|
462 | 483 | ```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> |
464 | 486 | ``` |
465 | 487 |
|
| 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 | +
|
466 | 491 | --- |
467 | 492 |
|
468 | 493 | ## Rollback Plan |
|
0 commit comments