Quick Fix: Run cf login -a API_ENDPOINT -u USERNAME -p PASSWORD, then cf push APP_NAME -p PATH_TO_APP — done in under 2 minutes.
What's Happening
You're trying to push a Spring Boot JAR or WAR to Cloud Foundry (CF) as of 2026. The CF CLI won't work unless you're logged in — you'll get Not logged in. Use 'cf login' if you're not. The CLI also needs a compiled artifact; if you skip compilation, the buildpack will throw an error. Honestly, this is the simplest way to shoot yourself in the foot.
Step-by-Step Solution
Here's the thing: you'll need a Linux, macOS, or Windows (WSL2) terminal with CF CLI v8.7+ installed. That's non-negotiable.
- Open your terminal and check the CLI version:
cf --versionYou should see something likecf version 8.7.0+... - Log in to your CF instance:
cf login -a https://api.run.pivotal.io -u your-email@domain.com -p "your-password"Swap out the API endpoint for your foundation’s URL (e.g.,https://api.sys.example.com). - Target the correct org and space (if the CLI prompts you):
cf target -o ORG_NAME -s SPACE_NAME - Compile your Spring Boot app:
./mvnw clean packageif you're using Maven./gradlew buildif you're on Gradle The artifact lands intarget/your-app.jarorbuild/libs/your-app.jar - Push the app (no manifest needed for a basic deploy):
cf push my-spring-app -p target/my-spring-app.jar --random-routeAdd--route-path /healthif you need a specific endpoint.
If This Didn't Work
- Buildpack issue: Tell CF exactly which buildpack to use:
cf push my-spring-app -p target/my-spring-app.jar -b "java_buildpack" --no-start - Memory too low: Give your app more RAM:
cf push my-spring-app -m 1G -p target/my-spring-app.jar - JDBC driver missing: Spin up a database service:
cf create-service elephantsql turtle my-dbThen attach it to your app either in a manifest underservices:or via CLI:cf bind-service my-spring-app my-db
Prevention Tips
- Create a
manifest.ymlfor repeatable deployments. Sample:Parameter Value applications - name: my-spring-app
memory: 1G
buildpacks: java_buildpack
path: target/my-spring-app.jar
services:- my-db
routes:- route: my-app.example.com - Lock your buildpack version in the manifest:
buildpacks: https://github.com/cloudfoundry/java-buildpack.git#v4.55 - Put secrets in a user-provided service instead of the manifest. Cloud Foundry banned inline credentials in manifests back in 2026 for security reasons.
- Turn on HTTP health checks:
cf set-health-check my-spring-app http --endpoint /actuator/health