Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed mentions of Java 8 #1614

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ For this guide we will be using Docker.
Create a `Dockerfile` in the project root directory:

```dockerfile {2}
FROM openjdk:8-jdk-alpine
FROM openjdk:17-jdk-alpine
ARG JAR_FILE=application/target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Expand Down
2 changes: 1 addition & 1 deletion docs-java_versioned_docs/version-v5/environments/kyma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ For this guide we will be using Docker.
Create a `Dockerfile` in the project root directory:

```dockerfile {2}
FROM openjdk:8-jdk-slim
FROM openjdk:17-jdk-slim
ARG JAR_FILE=application/target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
Expand Down
107 changes: 3 additions & 104 deletions docs-java_versioned_docs/version-v5/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,110 +32,9 @@ Be cautious about using features annotated as _Beta_ because their API can chang

### Which Java Versions Are Supported by the SAP Cloud SDK?

The SAP Cloud SDK itself is compatible with Java 8, 11 [and 17](#spring-boot-3-and-java-17-support).
Other Java versions may work as well, depending on your setup, but are not yet tested by us.
Note that the SAP Business Technology Platform Cloud Foundry environment only supports Java 8 out of the box, but can be configured to also run with Java 11 or 17.

#### Spring Boot 3 and Java 17 support

SAP Cloud SDK can be used with JakartaEE (e.g. via Spring Boot 3, Spring 6, and Java 17) thanks to the experimental module `servlet-jakarta`.

In case you are migrating your application from Spring Boot 2, the below steps make sure the Cloud SDK continues to work smoothly:

1. Set Spring Boot version to 3 and Java version to 17:

```xml
<properties>
<java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.testSource>${java.version}</maven.compiler.testSource>
<maven.compiler.testTarget>${java.version}</maven.compiler.testTarget>
</properties>
```

2. Place the Spring Boot dependency management **before** the SDK BOM:

```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sap.cloud.security</groupId>
<artifactId>java-bom</artifactId>
<version>3.1.3</version> <!-- TODO: replace this with the most recent version -->
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sap.cloud.sdk</groupId>
<artifactId>sdk-bom</artifactId>
<version>5.0.0</version> <!-- TODO: replace this with the most recent version -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
```

3. Replace any `javax` dependency with the respective `jakarta` dependency:

```diff
-<dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
-</dependency>
+<dependency>
+ <groupId>jakarta.inject</groupId>
+ <artifactId>jakarta.inject-api</artifactId>
+ <version>2.0.1</version>
+</dependency>
```

Don't forget to replace `javax` imports in Java files with `jakarta` imports.

Also remember to migrate all your dependencies to their respective `jakarta` versions if applicable.

For example, if you were previously using `com.sap.hcp.cf.logging:cf-java-logging-support-servlet` for application logging you must instead switch to using `com.sap.hcp.cf.logging:cf-java-logging-support-servlet-jakarta`.

```diff
-<dependency>
- <groupId>com.sap.hcp.cf.logging</groupId>
- <artifactId>cf-java-logging-support-servlet</artifactId>
-</dependency>
+<dependency>
+ <groupId>com.sap.hcp.cf.logging</groupId>
+ <artifactId>cf-java-logging-support-servlet-jakarta</artifactId>
+ <version>latest-lib-version</version>
+</dependency>
```

4. Add the new `servlet-jakarta` module:

```xml
<dependencies>
<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
<artifactId>servlet-jakarta</artifactId>
</dependency>
</dependencies>
```

5. When using the `@ServletComponentScan` annotation as suggested, please update the namespace:

```diff
- @ServletComponentScan({"com.sap.cloud.sdk", ...
+ @ServletComponentScan({"com.sap.cloud.sdk.cloudplatform.servletjakarta", ...
```

6. Configure Cloud Foundry for Java 17

- [Configure SAP Java Buildpack to run with Java 17](https://help.sap.com/docs/btp/sap-business-technology-platform/sapmachine#activation)
- Add the SAPMachine JRE version 17 in you `manifest.yml`:
```diff
env:
+ JBP_CONFIG_COMPONENTS: 'jres: [''com.sap.xs.java.buildpack.jre.SAPMachineJRE'']'
+ JBP_CONFIG_SAP_MACHINE_JRE: '{ use_offline_repository: false, version: 17.0.5 }'
```
The SAP Cloud SDK is compatible with Java 17 Long-Term-Support (LTS)
Newer Java versions may work as well depending on your setup but are not yet tested by us.
Note that the SAP Business Technology Platform Cloud Foundry environment can be configured to run with Java 17.

### Can I Use Features Annotated as Beta in Production?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ The decorator operates with two kinds of operations:
<tbody>
<tr>
<td>
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Callable.html">
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/Callable.html">
Callable
</a>
</td>
<td>May throw checked or unchecked Exceptions</td>
</tr>
<tr>
<td>
<a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html">
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/function/Supplier.html">
Supplier
</a>
</td>
Expand Down
133 changes: 6 additions & 127 deletions docs-java_versioned_docs/version-v5/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,102 +26,23 @@ To get started with the SAP Cloud SDK for Java you can either create a new proje
You will need an installation of Java and Maven.

:::note Java version compatibility
The SAP Cloud SDK is compatible with all current Long-Term-Support (LTS) releases of Java: 8, 11 [and 17](faq.mdx#spring-boot-3-and-java-17-support).
Other Java versions may work as well depending on your setup but are not yet tested by us.
Note that the SAP Business Technology Platform Cloud Foundry environment only supports Java 8 out of the box but can be configured to also run with Java 11 or 17.
The SAP Cloud SDK is compatible with Java 17 Long-Term-Support (LTS)
Newer Java versions may work as well depending on your setup but are not yet tested by us.
Note that the SAP Business Technology Platform Cloud Foundry environment can be configured to run with Java 17.
:::

To start with a clean, new project you can select [one of our archetypes](https://search.maven.org/search?q=com.sap.cloud.sdk.archetypes) and build upon it.
Alternatively, you can follow [these instructions](#integrate-the-cloud-sdk-for-java-into-your-project) to integrate the SAP Cloud SDK into your existing setup.

## Generating a Project from a Maven Archetype

The SAP Cloud SDK provides archetypes based on [Spring](https://spring.io/).
The SAP Cloud SDK provides an archetype based on [Spring 6](https://spring.io/).

Run:

<Tabs groupId="frameworks" defaultValue="spring5" values={[
{ label: 'Spring 5', value: 'spring5', },
{ label: 'Spring 6', value: 'spring6', }]}>

<TabItem value="spring5">

```bash
mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.sdk.archetypes" \
"-DarchetypeArtifactId=scp-cf-spring" \
"-DarchetypeVersion=RELEASE"
```

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 keeping `1.0-SNAPSHOT` if you're just starting
- `package` - by default this equals to `groupId`. 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:

```bash
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.1.2:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.1.2:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.1.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] ....
[INFO] ....
Define value for property 'groupId': foo.bar.cloud.app
Define value for property 'artifactId' (should match expression '[^_]+'): mydreamapp
[INFO] Using property: artifactId = mydreamapp
Define value for property 'version' 1.0-SNAPSHOT: :
Define value for property 'package' foo.bar.cloud.app: :
[INFO] Using property: gitignore = .gitignore
[INFO] Using property: skipUsageAnalytics = false
Confirm properties configuration:
groupId: foo.bar.cloud.app
artifactId: mydreamapp
artifactId: mydreamapp
version: 1.0-SNAPSHOT
package: foo.bar.cloud.app
gitignore: .gitignore
skipUsageAnalytics: false
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: scp-cf-spring:RELEASE
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: foo.bar.cloud.app
[INFO] Parameter: artifactId, Value: mydreamapp
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: foo.bar.cloud.app
[INFO] Parameter: packageInPathFormat, Value: foo/bar/cloud/app
[INFO] Parameter: package, Value: foo.bar.cloud.app
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: foo.bar.cloud.app
[INFO] Parameter: skipUsageAnalytics, Value: false
[INFO] Parameter: gitignore, Value: .gitignore
[INFO] Parameter: artifactId, Value: mydreamapp
[INFO] Project created from Archetype in dir: /home/user/dev/temp/mydreamapp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:28 min
[INFO] Finished at: 2020-04-19T19:25:33+02:00
[INFO] ------------------------------------------------------------------------
```

</TabItem>
<TabItem value="spring6">

```bash
mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.sdk.archetypes" \
"-DarchetypeArtifactId=scp-cf-spring-jakarta" \
"-DarchetypeArtifactId=spring-boot3" \
CharlesDuboisSAP marked this conversation as resolved.
Show resolved Hide resolved
"-DarchetypeVersion=RELEASE"
```

Expand Down Expand Up @@ -186,9 +107,6 @@ package: foo.bar.cloud.app
[INFO] ------------------------------------------------------------------------
```

</TabItem>
</Tabs>

**Congratulations! You've just set up a brand-new application with the SAP Cloud SDK for Java.**

:::tip
Expand Down Expand Up @@ -276,13 +194,7 @@ In general, the SAP Cloud SDK for Java integrates natively into the [Spring Boot
In particular the [SAP Cloud SDK provides listeners](features/multi-tenancy/thread-context.mdx) that can extract tenant and principal information from an incoming request.
To ensure these listeners are present, please configure your project accordingly.

<Tabs groupId="frameworks" defaultValue="spring5" values={[
{ label: 'Spring 5', value: 'spring5', },
{ label: 'Spring 6', value: 'spring6', }]}>

<TabItem value="spring5">

For a **Spring 5** based project please ensure that the application is annotated to scan for components of the SAP Cloud SDK:
Please ensure that the application is annotated to scan for components of the SAP Cloud SDK:

```java
@ComponentScan({"com.sap.cloud.sdk", <your.own.package>})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs the Jakarta annotation instead

Copy link
Contributor Author

@CharlesDuboisSAP CharlesDuboisSAP Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the workaround:

@ServletComponentScan({"com.sap.cloud.sdk.cloudplatform.servletjakarta", <your.own.package>})

Meaning that applications can go back to:

@ServletComponentScan({"com.sap.cloud.sdk", <your.own.package>})

Because it will find the only servlet which is jakarta-servlet

Expand All @@ -291,39 +203,6 @@ For a **Spring 5** based project please ensure that the application is annotated

Also, please check [the Spring version](https://mvnrepository.com/artifact/com.sap.cloud.sdk/sdk-bom/latest) declared in the SAP Cloud SDK BOM doesn't clash with your version of Spring.

:::note Spring Support for Cloud Foundry
For Spring based projects we provide out-of-the-box support only on Cloud Foundry with the archetype `scp-cf-spring`.
:::

</TabItem>
<TabItem value="spring6">

For a **Spring 6** based project please ensure that the application is annotated to scan for components of the SAP Cloud SDK:

```java
@ComponentScan({"com.sap.cloud.sdk", <your.own.package>})
@ServletComponentScan({"com.sap.cloud.sdk.cloudplatform.servletjakarta", <your.own.package>})
```

Add the jakarta servlet dependency to your pom.xml:

```xml
<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
<artifactId>servlet-jakarta</artifactId>
</dependency>
```

And, in case you are using the `sdk-bom`, make sure to set the Spring and XSUAA Library versions before importing the bom.
You can find more details about the configuration for Java 17 / Spring 6 / Spring Boot 3 [here](/docs/java/frequently-asked-questions#which-java-versions-are-supported-by-the-sap-cloud-sdk).

:::note Spring Support for Cloud Foundry
For Spring based projects we provide out-of-the-box support only on Cloud Foundry with the archetype `scp-cf-spring`.
:::

</TabItem>
</Tabs>

:::note 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.
Expand Down
Loading
Loading