You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/container-dist_zip.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The Dist Zip Container allows applications packaged in [`distZip`-style][] to be
16
16
</table>
17
17
Tags are printed to standard output by the buildpack detect script
18
18
19
-
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.
19
+
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The [Java CfEnv](framework-java-cfenv.md) framework — the replacement for the deprecated Spring Auto-reconfiguration — activates the `cloud` profile at runtime; you can also add it explicitly with `SPRING_PROFILES_INCLUDE=cloud`.
20
20
21
21
## Configuration
22
22
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].
Copy file name to clipboardExpand all lines: docs/container-java_main.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Command line arguments may optionally be configured.
19
19
</table>
20
20
Tags are printed to standard output by the buildpack detect script
21
21
22
-
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.
22
+
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The [Java CfEnv](framework-java-cfenv.md) framework — the replacement for the deprecated Spring Auto-reconfiguration — activates the `cloud` profile at runtime; you can also add it explicitly with `SPRING_PROFILES_INCLUDE=cloud`.
Copy file name to clipboardExpand all lines: docs/container-spring_boot.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Tags are printed to standard output by the buildpack detect script
15
15
16
16
The container expects to run the application creating by running [`gradle distZip`][d] in an application built with the Spring Boot Gradle plugin.
17
17
18
-
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.
18
+
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The [Java CfEnv](framework-java-cfenv.md) framework — the replacement for the deprecated Spring Auto-reconfiguration — activates the `cloud` profile at runtime; you can also add it explicitly with `SPRING_PROFILES_INCLUDE=cloud`.
Copy file name to clipboardExpand all lines: docs/container-spring_boot_cli.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The Spring Boot CLI Container runs one or more Groovy (i.e. `*.groovy`) files us
19
19
</table>
20
20
Tags are printed to standard output by the buildpack detect script.
21
21
22
-
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.
22
+
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The [Java CfEnv](framework-java-cfenv.md) framework — the replacement for the deprecated Spring Auto-reconfiguration — activates the `cloud` profile at runtime; you can also add it explicitly with `SPRING_PROFILES_INCLUDE=cloud`.
23
23
24
24
## Configuration
25
25
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].
The Java CfEnv Framework provides the `java-cfenv` library for Spring Boot 3+ applications. This library sets various Spring Boot properties by parsing CloudFoundry variables such as `VCAP_SERVICES`, allowing Spring Boot's autoconfiguration to kick in.
2
+
The Java CfEnv Framework provides the `java-cfenv` library for Spring Boot 3.x and 4.x applications. This library sets various Spring Boot properties by parsing Cloud Foundry variables such as `VCAP_SERVICES`, allowing Spring Boot's autoconfiguration to kick in.
3
3
4
-
This is the recommended replacement for Spring AutoReconfiguration library which is deprecated. See the `java-cfenv` <ahref="https://github.com/pivotal-cf/java-cfenv">repostitory</a> for more detail.
4
+
This is the recommended replacement for Spring AutoReconfiguration library which is deprecated. See the `java-cfenv` <ahref="https://github.com/pivotal-cf/java-cfenv">repository</a> for more details.
5
5
6
-
It also sets the 'cloud' profile for Spring Boot applications, as the Spring AutoReconfiguration framework did.
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.
7
+
8
+
The buildpack selects the appropriate `java-cfenv` version based on the detected Spring Boot major version:
9
+
10
+
| Spring Boot | java-cfenv |
11
+
|-------------|------------|
12
+
| 3.x | 3.x (latest) |
13
+
| 4.x | 4.x (latest) |
7
14
8
15
<table>
9
16
<tr>
10
17
<td><strong>Detection Criterion</strong></td>
11
-
<td>Existence of a `Spring-Boot-Version: 3.*` manifest entry</td>
12
-
<td>No existing `java-cfenv` library found</td>
18
+
<td>Existence of a <tt>spring-boot-3.*.jar</tt> or <tt>spring-boot-4.*.jar</tt> in <tt>BOOT-INF/lib</tt>, <tt>WEB-INF/lib</tt>, or <tt>lib/</tt>; or a <tt>Spring-Boot-Version: 3.*</tt> / <tt>Spring-Boot-Version: 4.*</tt> entry in <tt>META-INF/MANIFEST.MF</tt></td>
19
+
<td>No existing <tt>java-cfenv</tt> library found in the application</td>
13
20
</tr>
14
21
<tr>
15
22
<td><strong>Tags</strong></td>
16
23
<td><tt>java-cf-env=<version></tt></td>
17
24
</tr>
18
25
</table>
19
26
Tags are printed to standard output by the buildpack detect script
27
+
28
+
## How it works
29
+
30
+
The framework is implemented in `src/java/frameworks/java_cf_env.go`:
31
+
32
+
1.**Detect** — activates only when all of these hold: the framework is enabled (see [Configuration](#configuration)); a Spring Boot 3.x or 4.x marker is found (a `spring-boot-{3,4}.*.jar` under `BOOT-INF/lib`, `WEB-INF/lib`, or `lib/`, or a `Spring-Boot-Version: 3.*` / `4.*` entry in `META-INF/MANIFEST.MF`); and the application does not already bundle a `java-cfenv*.jar` (if it does, the buildpack backs off and uses the application's own copy).
33
+
2.**Supply** — selects the java-cfenv version from the detected Spring Boot major (Spring Boot 3 → the manifest's `3.x` line, Spring Boot 4 → the `4.x` line) and installs the `java-cfenv-all` jar into the dependency directory.
34
+
3.**Finalize** — appends the installed jar to `CLASSPATH` via a `.profile.d/java_cf_env.sh` script, so it is on the application's runtime classpath.
35
+
4.**Runtime** — Spring Boot reads the jar's `META-INF/spring.factories`: the `EnvironmentPostProcessor`s map `VCAP_SERVICES` to Spring properties, and `CloudProfileApplicationListener` (in the `java-cfenv-all` module) activates the `cloud` profile when running in Cloud Foundry.
36
+
37
+
## Configuration
38
+
39
+
The framework can be disabled via the `JBP_CONFIG_JAVA_CF_ENV` environment variable:
The buildpack only re-reads this variable during staging, so a `cf restage` is required for the change to take effect.
47
+
48
+
To re-enable, either set it back to `{enabled: true}` or remove the variable entirely:
49
+
50
+
```bash
51
+
cf unset-env <app> JBP_CONFIG_JAVA_CF_ENV
52
+
cf restage <app>
53
+
```
54
+
55
+
| Variable | Default | Description |
56
+
|----------|---------|-------------|
57
+
|`JBP_CONFIG_JAVA_CF_ENV`|`{enabled: true}`| Enable or disable the framework |
58
+
59
+
Note: if `java-cfenv*.jar` is already present in the application, the buildpack skips injection automatically — no need to disable explicitly for that case.
60
+
61
+
Disable when:
62
+
- The application handles `VCAP_SERVICES` manually with custom binding logic
63
+
- The automatic `cloud` profile activation is unwanted
64
+
- Another service binding library conflicts with `java-cfenv`
65
+
66
+
`{enabled: false}` disables the **whole** framework — both the `VCAP_SERVICES` → Spring property mapping and the `cloud` profile activation. There is no option to disable only the `cloud` profile.
67
+
68
+
For finer control, bundle a java-cfenv artifact in the application yourself. Because the buildpack backs off whenever a `java-cfenv*.jar` is already present, the app's choice wins:
|`java-cfenv-all`| yes | yes (app pins the version) |
74
+
|`java-cfenv-boot`| yes |**no** (no `CloudProfileApplicationListener`) |
75
+
|`java-cfenv` (core) |**no** (API only) |**no**|
76
+
77
+
So an app can include `java-cfenv-boot` to keep property mapping without the `cloud` profile, or the bare `java-cfenv` core to opt out of all automatic behaviour and use the `CfEnv` API directly.
>**whole** framework — both property mapping and the `cloud` profile. There is no
29
+
>`cloud`-profile-only toggle.
30
+
> - Because the buildpack backs off when the app already bundles a `java-cfenv*.jar`, bundling your
31
+
> own artifact wins: `java-cfenv-boot` = property mapping without the `cloud` profile;
32
+
>`java-cfenv` (core) = neither, use the `CfEnv` API directly.
33
+
>
34
+
> See [Java CfEnv Framework](framework-java-cfenv.md) for details.
35
+
36
+
>**Note — backwards compatible with buildpack 4.x (java-buildpack 5.0.6+)**
37
+
>
38
+
> As of java-buildpack **5.0.6**, the buildpack injects `java-cfenv-all` by default, so the `cloud`
39
+
> profile activation and the `VCAP_SERVICES` → Spring property mapping behave the same as under
40
+
> java-buildpack 4.x. Apps that relied on either under 4.x keep working after upgrading — no
41
+
> application change is required for the `cloud`/VCAP behaviour. (Buildpack 5.0.0–5.0.5 shipped the
42
+
> bare `java-cfenv` core module, which activated neither; see #1349.)
43
+
5
44
---
6
45
7
46
## Table of Contents
@@ -52,8 +91,9 @@ This guide provides step-by-step instructions for migrating from the deprecated
52
91
<!-- Add to your pom.xml -->
53
92
<dependency>
54
93
<groupId>io.pivotal.cfenv</groupId>
55
-
<artifactId>java-cfenv-boot</artifactId>
56
-
<version>3.1.4</version>
94
+
<artifactId>java-cfenv-all</artifactId>
95
+
<!-- match your Spring Boot major: 3.5.1 for Spring Boot 3, 4.0.0 for Spring Boot 4 -->
96
+
<version>3.5.1</version>
57
97
</dependency>
58
98
```
59
99
@@ -62,6 +102,7 @@ This guide provides step-by-step instructions for migrating from the deprecated
62
102
- Library reads `VCAP_SERVICES` and sets Spring Boot properties
63
103
- Spring Boot autoconfiguration uses these properties
64
104
- More transparent and Spring Boot native
105
+
- `java-cfenv-all` bundles the property post-processors **and** the `cloud` profile listener (`CloudProfileApplicationListener`); use the lighter `java-cfenv-boot` instead only if you do not rely on the `cloud` profile
65
106
66
107
---
67
108
@@ -91,11 +132,11 @@ Check your `pom.xml` or `build.gradle`:
91
132
92
133
```xml
93
134
<dependencies>
94
-
<!-- Add this dependency -->
135
+
<!-- Add this dependency (match your Spring Boot major: 3.5.1 for Spring Boot 3, 4.0.0 for Spring Boot 4) -->
95
136
<dependency>
96
137
<groupId>io.pivotal.cfenv</groupId>
97
-
<artifactId>java-cfenv-boot</artifactId>
98
-
<version>3.1.4</version>
138
+
<artifactId>java-cfenv-all</artifactId>
139
+
<version>3.5.1</version>
99
140
</dependency>
100
141
</dependencies>
101
142
```
@@ -104,7 +145,7 @@ Check your `pom.xml` or `build.gradle`:
0 commit comments