Getting Started
To get started with the SAP Cloud SDK for Java you can either create a new project or integrate the SAP Cloud SDK into your existing one. You will need an installation of Java and Maven.
Java version compatibility
The SAP Cloud SDK itself is compatible with Java 8 and 11. Other Java versions may work as well depending on your setup but are not yet tested by us. Note that the SAP Cloud Platform Cloud Foundry environment only supports Java 8 out of the box but can be configured to also run with Java 11. SAP Cloud Platform Neo only supports Java 8.
To start with a clean, new project you can select one of our archetypes and build upon it. Alternatively, you can follow these instructions to integrate the SAP Cloud SDK into your existing setup.
#
Generating a Project from a Maven Archetype- Spring
- TomEE
Maven will ask you to provide the following:
groupId
- usually serves as your organization identifier, i.e.foo.bar.cloud.app
artifactId
- it's your application's name, i.e.mydreamapp
version
- we recommend keeping1.0-SNAPSHOT
if you're just startingpackage
- by default this equals togroupId
. Change it only if you know what you're doing
After providing all the interactive values to the CLI it will generate your first SAP Cloud SDK based application:
Congratulations! You've just set up a brand new application with the SAP Cloud SDK for Java.
tip
To change the Java version modify the <java.version>
property in the root pom.xml
.
#
Integrate the SAP Cloud SDK for Java Into Your Project#
Adding Dependenciestip
The SAP Cloud SDK integrates with CAP projects! Follow the steps below or check out the dedicated tutorial on SAP Developers.
To get started with an existing project include the SAP Cloud SDK BOM in the dependency management section of your project:
If your application is running on SAP Cloud Platform please add the appropriate dependency:
- Cloud Foundry
- Neo
If you want to connect to an SAP S/4HANA system via the OData protocol you should also add a dependency to the client libraries of the SAP Cloud SDK. The dependencies differ with respect to the type of SAP S/4HANA system(SAP S/4HANA Cloud or SAP S/4HANA On-Premise 2020):
- SAP S/4HANA Cloud
- SAP S/4HANA On-Premise 2020
In case you have a CAP application which uses multitenancy features and/or a protected backend your service will need the following dependency:
We also recommend that you include the following plugin:
It sends anonymized usage data such as the SAP Cloud SDK version used and helps us with improving the SAP Cloud SDK.
Furthermore, the plugin is capable of generating a report with useful information about the project setup.
Invoking diagnosis-report
will print out the SAP Cloud SDK modules used and their version but also other information like the Java and Maven version.
This is helpful when you are facing an issue and are reaching out to us for help.
#
Framework IntegrationIn general, the SAP Cloud SDK for Java integrates natively into the Spring Boot and TomEE frameworks.
In particular the SAP Cloud SDK provides listeners that can extract tenant and principal information from an incoming request. To ensure these listeners are present, please configure your project accordingly.
- Spring
- TomEE
For a Spring based project please ensure that the application is annotated to scan for components of the SAP Cloud SDK:
Check the logs during application startup to ensure the listeners got registered. Also please check the Spring version declared in the SAP Cloud SDK BOM doesn't clash with your version of Spring.
Spring Support for Cloud Foundry
For Spring based projects we provide out-of-the-box support only on Cloud Foundry with archetype scp-cf-spring
.
For a TomEE based project, the filters should be registered automatically.
They are part of the servlet
module which comes into the dependency tree through scp-cf
or scp-neo
automatically.
Check the logs during application startup to ensure the listeners got registered.
SAP Cloud SDK Modules Bill-of-Material
By default, the SAP Cloud SDK archetypes reference the SAP Cloud SDK Bill-of-Material sdk-bom
, which manages dependency versions for all SAP Cloud SDK modules and transitive dependencies.
If you face dependency conflicts, you can instead try using the SAP Cloud SDK Modules Bill-of-Material sdk-modules-bom
in the dependencyManagement
section of your Maven POM file.
#
Next Steps- Configure you IDE
- Get and bind SAP Cloud Foundry CLI
- Check tutorials for SAP Cloud SDK for Java
- Check out key Features and Guides sections
- Check our release notes