Configuring Applications
Profiles and Properties
This section describes how to configure applications. CAP Java applications can fully leverage Spring Boot's capabilities for Externalized Configuration. This enables you to define multiple configuration profiles for different scenarios, like local development and cloud deployment.
For a first introduction, have a look at our sample application and the configuration profiles we added there.
Now, that you're familiar with how to configure your application, start to create your own application configuration. See the full list of CDS properties as a reference.
Production Profile
When running your application in production, it makes sense to strictly disable some development-oriented features. The production profile configures a set of selected property defaults, recommended for production deployments, at once. By default the production profile is set to cloud. To specify a custom production profile, set cds.environment.production.profile to a Spring profile used in your production deployments.
Production profile = cloud
The Java Buildpacks set the cloud profile for applications by default. Other active profiles for production deployments are typically set using the environment variable SPRING_PROFILES_ACTIVE on your application in your deployment descriptors (mta.yaml, Helm charts, etc.).
Property defaults adjusted with the production profile are the following:
- Index Page is disabled:
cds.index-page.enabledis set tofalse - Mock Users are strictly disabled:
cds.security.mock.enabledis set tofalse - Access for internal testing is disabled:
cds.security.authentication.internalUserAccess.enabledis set tofalse
Note, that explicit configuration in the application takes precedence over property defaults from the production profile.
Warning
Do not manually enable features for production that are disabled by the production profile, as this could introduce serious security vulnerabilities.
Using SAP Java Buildpack
In SAP BTP Cloud Foundry environment, the Java runtime that is used to run your application is defined by the so-called buildpack. For CAP applications, we advise you to use the SAP Java Buildpack 2. CAP applications built with Spring Boot don't require any specific configuration for the buildpack and run using Java Main runtime by default.
To configure the buildpack for Java 21 with SapMachine JRE, add the following lines to your mta.yaml right under your Java service definition:
parameters:
buildpack: sap_java_buildpack_jakarta
properties:
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jre.SAPMachineJRE']"
JBP_CONFIG_SAP_MACHINE_JRE: '{ version: 21.+ }'SAP Business Application Studio
If you develop your application in SAP Business Application Studio and Java 21 is not available there, use the Java 17, instead.